Skip to content

feat(issue): accept a bare issue key for issuelink fields - #10

Merged
Spenhouet merged 2 commits into
mainfrom
feat/issuelink-bare-key
Aug 14, 2026
Merged

Spenhouet merged 2 commits into
mainfrom
feat/issuelink-bare-key

Conversation

@Spenhouet

Copy link
Copy Markdown
Owner

Problem

coerce_value had no branch for the issuelink schema type, so a parent or linked-issue field fell through to the catch-all: try json.loads, otherwise send the raw string. Setting an epic therefore required hand-writing the object:

bj issue edit PROJ-42 --field 'Parent={"key":"PROJ-1"}'   # works
bj issue edit PROJ-42 --field 'Parent=PROJ-1'             # parent: data was not an object

The error names the field and the shape it wanted, but not the syntax that would satisfy it.

Change

Coerce issuelink fields the same way the other object-shaped types are already coerced (priority, version, component, resolution, project): a bare key becomes {"key": "PROJ-1"}, an all-digit value becomes {"id": "10023"}, and a value that already looks like JSON is parsed and passed through unchanged. Malformed JSON falls back to the key form rather than raising.

Testing

  • New tests/test_jira_fields.py, the module had no tests. 18 cases covering field resolution by id, display name and hyphenated name, the unknown-field error, all four issuelink paths, and the existing number, array, option, unknown-type and user-type behaviour.
  • uv run pytest: 114 passed. uv run ruff check: clean.
  • Live check against a Jira Cloud site: bj issue edit AIRA-3789 --field 'Parent=AIRA-3775' succeeded and reading the issue back shows parent: AIRA-3775.

Note

#9 documents the old object-only form. Its wording needs one line updated once this lands, whichever order the two merge in.

Sebastian Penhouet added 2 commits August 14, 2026 11:10
Setting a parent or any other issuelink field meant hand-writing the JSON
object the API wants, because the coercion had no branch for the type and
fell through to "parse as JSON, else send the string". A bare key came back
as `parent: data was not an object`, which says nothing about the fix.

Coerce issuelink fields to {"key": ...} for a key and {"id": ...} for a
numeric id, so `--field Parent=PROJ-1` works. An explicit JSON object is
still passed through unchanged.
@Spenhouet
Spenhouet force-pushed the feat/issuelink-bare-key branch from 882cc55 to 687ab07 Compare August 14, 2026 09:11
@Spenhouet
Spenhouet merged commit a3149a5 into main Aug 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant