format: stop leaking relationship IDs into JSON:API attributes in --json/--jq - #79
Merged
brandonc merged 1 commit intoJul 14, 2026
Conversation
resourceAsMap pulled one-to-one relationship IDs up into the attributes map for table and pretty display, but that map is shared with the raw payload backing --json and --jq output. The pulled-up IDs then appeared under "attributes" in JSON output, keys the server never returned there. Write the pulled-up IDs into the per-display row instead of mutating the shared attributes map. Adds tests asserting JSON output is unpolluted and the raw payload is stable across table and JSON rendering.
jordanenglish
marked this pull request as ready for review
July 13, 2026 17:56
brandonc
approved these changes
Jul 14, 2026
Collaborator
|
Thanks again! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
For
tfctl api, one-to-one relationship IDs are pulled up into the flattenedrow so they show in table and pretty output (e.g. an
organizationcolumn).resourceAsMapdid this by writing the ID into the resource'sattributesmap, but that map is aliased from the raw JSON:API payload that backs
--jsonand
--jqoutput. As a result the pulled-up IDs leaked intoattributesinJSON output, keys the server never returned under
attributes, corruptingmachine-readable output.
This writes the pulled-up relationship IDs into the per-display row instead of
mutating the shared
attributesmap, so table/pretty output is unchanged while--json/--jqreflect the server payload exactly.Example Output
Given a workspace with an
organizationrelationship, before:After:
PR Checklist
npx changie newor install changie to prepare a new changelog entry for the next set of release notes..changes/unreleased/BUG FIXES-*.yaml(kind: BUG FIXES).--json— Force machine readable output to stdout. Does not apply to stderr.--markdown— Force markdown output to stdout. Does not apply to stderr.--dry-run— Don't make any actual writes or other mutations. Describe what would have changed to stderr.--quiet— Don't render output to stdout.--json/--jqoutput. Table/pretty (--markdownincluded) output is unchanged; a regression test confirms the existing pull-up display behavior still holds.make gen/screenshotif the root command output changes.Autocompletefield to positional arguments and flags to assist shell autocomplete.PCI review checklist
I have documented a clear reason for, and description of, the change I am making.
If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
If applicable, I've documented the impact of any changes to security controls.