Skip to content

Hotfix: tolerate flattened provisioning response - #5

Merged
njb90 merged 1 commit into
mainfrom
fix-flat-response
Aug 5, 2026
Merged

Hotfix: tolerate flattened provisioning response#5
njb90 merged 1 commit into
mainfrom
fix-flat-response

Conversation

@njb90

@njb90 njb90 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

npx @cloudinary/cloud@0.1.0 crashes with Cannot read properties of undefined (reading '0') — the live API now returns the environment fields flattened onto the account object, with no product_environments array. Worse, the crash happens after provisioning, so the cloud is created and its credentials discarded.

Fix, at the API boundary only (provisionCloud):

  • Normalize both observed shapes (nested product_environments[] and flat) into the nested contract — downstream code untouched; credential extraction already tolerated flat fields at the environment level.
  • An unrecognized success shape now throws a ProvisionError that includes the raw response, so a future drift can never silently cost the caller their only copy of the credentials.

Version bumped to 0.1.1.

Test plan

  • Two new tests: flat-shape normalization, unrecognized-shape error preserving the raw body — 54/54 pass
  • Live smoke test against the production endpoint with the fixed build: exit 0, credentials extracted, .env created with mode 0600

🤖 Generated with Claude Code

The API now returns the environment's fields on the account object
itself, with no product_environments array, so 0.1.0 crashes reading
product_environments[0] after the cloud was already created. Normalize
both shapes at the API boundary; an unrecognized success shape now
throws with the raw response included so credentials are never lost.
@njb90
njb90 merged commit 7a73118 into main Aug 5, 2026
4 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