Skip to content

Conversation

@tjb9dc
Copy link
Collaborator

@tjb9dc tjb9dc commented Dec 8, 2025

Description

Refs: https://github.com/fern-demo/uipath-typescript/commit/cde7c73511239a0bc22deb07d709f5b606379583

Fixes a bug where the TypeScript SDK generator produced invalid JavaScript when file upload request parameters had property names containing hyphens (e.g., header names like X-Custom-Header).

Changes Made

  • Modified FileUploadRequestParameter.getReferenceToProperty() to use bracket notation (request["X-Custom-Header"]) instead of dot notation when the property name is not a valid JavaScript identifier
  • Added shared isValidIdentifier() utility to @fern-typescript/commons using esutils.keyword.isIdentifierNameES6 for proper ES6 identifier validation
  • Added changelog entry for version 3.38.4

Before (invalid JS - interpreted as subtraction):

request.X - Custom - Header != null
    ? request.X - Custom - Header.toString()
    : undefined

After (valid JS):

request["X-Custom-Header"] != null
    ? request["X-Custom-Header"].toString()
    : undefined

Updates since last revision

  • Refactored to use shared isValidIdentifier utility from @fern-typescript/commons instead of a local regex, per reviewer feedback
  • The utility uses esutils.keyword.isIdentifierNameES6 which is already used elsewhere in the codebase (e.g., getPropertyKey.ts)
  • Merged with main branch and updated version to 3.38.4

Testing

  • Manual code review - verified the fix matches the pattern used in GeneratedQueryParams.ts which already uses createElementAccessExpression for similar cases
  • Unit tests added/updated

Human Review Checklist

  • Verify esutils.keyword.isIdentifierNameES6("X-Custom-Header") returns false (triggering bracket notation)
  • Consider if a seed test fixture should be added for regression coverage
  • Consider if the new shared isValidIdentifier utility needs unit tests

Link to Devin run: https://app.devin.ai/sessions/0522dde80b444962aea65de6933ee41a
Requested by: [email protected] (@tjb9dc)

@devin-ai-integration
Copy link
Contributor

🤖 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

@fern-support fern-support changed the title fix(ts-sdk): use bracket notation for non-identifier property names in file upload requests fix(typescript): use bracket notation for non-identifier property names in file upload requests Dec 8, 2025
return ts.factory.createPropertyAccessExpression(requestIdentifier, propertyName);
}

private isValidIdentifier(name: string): boolean {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have utilities to do this elsewhere?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call – I found that @fern-typescript/commons already uses esutils.keyword.isIdentifierNameES6 in getPropertyKey.ts for this exact purpose. I've added a shared isValidIdentifier utility to the commons package and updated this file to use it instead of the custom regex. This gives us full ES6 identifier coverage and keeps the codebase consistent.

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