Skip to content

fix: --json output fails with a circular structure error - #10

Merged
njb90 merged 1 commit into
mainfrom
fix-json-circular
Aug 26, 2026
Merged

fix: --json output fails with a circular structure error#10
njb90 merged 1 commit into
mainfrom
fix-json-circular

Conversation

@njb90

@njb90 njb90 commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Problem

npx @cloudinary/cloud --json fails after a successful provision:

Error: Converting circular structure to JSON
    --> starting at object with constructor 'Array'
    |     index 0 -> object with constructor 'Object'
    --- property 'product_environments' closes the circle

When the API returns the flattened response shape (environment fields directly on the account object), normalizeAccount rebuilt the nested product_environments contract by inserting the account object into its own array. The human and plain output modes read individual fields and were unaffected, but --json stringifies the whole account and throws. The cloud is still provisioned when this happens, so the caller loses the credentials from their output.

Fix

Insert a shallow copy of the environment fields (minus product_environments) instead of a self-reference, keeping the account JSON-serializable.

Testing

  • Added a regression test: provisions against the flat-shape stub and asserts the result round-trips through JSON.stringify.
  • Full suite passes (65/65).

🤖 Generated with Claude Code

… shape

The flattened response was normalized by inserting the account object
into its own product_environments array, which made --json output fail
with "Converting circular structure to JSON". Insert a copy instead.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@njb90
njb90 merged commit 156863c into main Aug 26, 2026
4 checks passed
@njb90 njb90 mentioned this pull request Aug 26, 2026
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