Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Description

Fixes a regression where validateAndTransformExtendedObject in the TypeScript generator's runtime was missing a null/undefined guard, causing "Cannot convert undefined or null to object" errors when parsing extended object schemas.

Context: This bug was originally fixed in PR #10214 (CLI v0.101.3) but was accidentally reverted when the docs-yml SDK was regenerated. Since packages/cli/configuration/src/docs-yml/schemas/sdk/ is generated code, this PR fixes the issue at the source - in the TypeScript generator's runtime - so it won't be overwritten on future regenerations.

Reported by: [email protected] via Slack
Devin session: https://app.devin.ai/sessions/7086562bf0844761889ba0feaea8354e

Changes Made

  • Added isPlainObject() validation check to validateAndTransformExtendedObject before calling Object.keys()
  • Updated function signature to accept value: unknown instead of value: object for safer type checking
  • Added breadcrumbsPrefix parameter for better error messages in validation failures
  • Removed unsafe type assertions (as object) when calling the function
  • Bumped TypeScript SDK generator version to 3.33.1 with appropriate changelog entry

Testing

  • Lint checks passed (pnpm run check)
  • Seed tests for TypeScript generator (not run - reviewer should verify if needed)
  • Manual testing (not performed - needs follow-up to regenerate docs-yml SDK)

Important Notes for Reviewers

  1. Incomplete investigation: The original stack trace mentioned both validateAndTransformExtendedObject and validateAndTransformUndiscriminatedUnion. This PR only fixes the former - please verify if the latter also needs a similar guard.

  2. Follow-up required: After this PR merges and the generator is published, a follow-up PR will be needed to:

    • Update fern/apis/docs-yml/generators.yml to use the new generator version (3.33.1)
    • Regenerate the docs-yml SDK to include this fix
    • Test that the original error no longer occurs
  3. Seed tests: Consider running TypeScript generator seed tests before merging, as this change affects a core schema validation function used across all generated TypeScript SDKs.

  4. Type safety improvement: Changing value: object to value: unknown is technically a breaking change in the function signature, but it's safer and more correct. The guard ensures we only proceed with actual objects.

…ndedObject

Adds isPlainObject() validation check to validateAndTransformExtendedObject
to prevent 'Cannot convert undefined or null to object' errors when parsing
extended object schemas. This mirrors the existing guard in validateAndTransformObject.

Also updates the function signature to accept unknown instead of object and
adds breadcrumbsPrefix parameter for better error messages.

This fix prevents the error from being reintroduced when the docs-yml SDK
is regenerated, as it's now in the TypeScript generator's runtime source.

Co-Authored-By: [email protected] <[email protected]>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants