Skip to content

KeyError when using cp command to copy attachments from hooks

For a workflow having the following hooks:

hooks:
- name: attach
  events:
  - channel: teardown
  before:
  - run: echo "hook"
  - run: echo "::attach::/home/user/docs/2.txt"
  - uses: actions/get-file@v1
    with:
      path: 1.txt
    working-directory: /home/user/docs

When trying to download all attachments with opentf-ctl cp {wf_id}:* ., the following error is thrown:

File ".../ctlattachments.py", line 224, in _make_target_path
'path': f"./{data['job']['name']}/{parent_step['sequence_id']}_{parent_step['testcase']}",
KeyError: 'testcase'

parent_step, in this case, is retrieved, but contains only 'sequence_id': None key-value pair.

Single attachment can still be downloaded wihtout problem.

(Also, for an attachement retrieved directly with ::attach:: command from a workflow (not hook) step, get attachments command output display nothing in "Testcase" column. Normally, <none> should be displayed... To check.)

Edited by Maria Einman