Hotfix: tolerate flattened provisioning response - #5
Merged
Conversation
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.
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.
Summary
npx @cloudinary/cloud@0.1.0crashes withCannot read properties of undefined (reading '0')— the live API now returns the environment fields flattened onto the account object, with noproduct_environmentsarray. Worse, the crash happens after provisioning, so the cloud is created and its credentials discarded.Fix, at the API boundary only (
provisionCloud):product_environments[]and flat) into the nested contract — downstream code untouched; credential extraction already tolerated flat fields at the environment level.ProvisionErrorthat 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
.envcreated with mode 0600🤖 Generated with Claude Code