Skip to content

fix(code-help): correct the identity and segment snippets - #8146

Merged
kyle-ssg merged 1 commit into
mainfrom
fix/code-help-traits-snippets
Jul 29, 2026
Merged

fix(code-help): correct the identity and segment snippets#8146
kyle-ssg merged 1 commit into
mainfrom
fix/code-help-traits-snippets

Conversation

@talissoncosta

Copy link
Copy Markdown
Contributor
  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Split out of #8145, which fixes the same class of bug in the snippets the onboarding renders. These eleven render on the Identity, Identities and Segments pages instead.

Two bugs:

  • A stray false in the output. Ten templates used ${cond && \…`}inside a template literal, which renders the stringfalsewhencondis false, i.e. on SaaS. The iOS snippet readFlagsmith.shared.apiKey = "KEY"false`. Now a ternary with an empty fallback.
  • The Node snippets don't run. They import a default export @flagsmith/nodejs doesn't have, so the first line throws SyntaxError: The requested module '@flagsmith/nodejs' does not provide an export named 'default'. It's import { Flagsmith }, which is what docs/integrating-with-flagsmith/sdks/server-side.mdx:257 already shows.

How did you test this code?

The Node import is verified in #8145, where the same fix to init-node.js was executed against @flagsmith/nodejs@9: it throws before the change and reaches the network call after.

The false fix is verified by rendering: every template was rendered with a non-custom API URL and checked for a boolean glued onto the preceding value. #8145 adds a unit test asserting exactly that for the init snippets.

  • Identity page → the traits snippets for Java, Node, PHP, Ruby and Rust contain no stray false
  • Identities page → the create-user snippets for iOS, Java, Node, PHP, Ruby and Rust contain no stray false
  • Segments page → the traits snippets render the same
  • Node snippet on either page starts with import { Flagsmith } from "@flagsmith/nodejs"

These snippets render on the Identity, Identities and Segments pages.

- `cond && \`...\`` inside a template literal renders the string "false" into
  the snippet whenever the API URL is not custom, i.e. on SaaS. Ten templates
  did this, so the output read `apiKey = "KEY"false`.
- The Node snippets imported a default export @flagsmith/nodejs does not have.
  It is `import { Flagsmith }`, as docs/.../server-side.mdx already shows;
  without it the snippet throws SyntaxError on the first line.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@talissoncosta
talissoncosta requested a review from a team as a code owner July 28, 2026 20:04
@talissoncosta
talissoncosta requested review from kyle-ssg and removed request for a team July 28, 2026 20:04
@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
flagsmith-frontend-preview Ready Ready Preview, Comment Jul 28, 2026 8:05pm
flagsmith-frontend-staging Ready Ready Preview, Comment Jul 28, 2026 8:05pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview Jul 28, 2026 8:05pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: bdcf3b16-107e-451d-8aac-13cef2571bf9

📥 Commits

Reviewing files that changed from the base of the PR and between b8073b9 and b437d63.

📒 Files selected for processing (11)
  • frontend/common/code-help/create-user/create-user-ios.js
  • frontend/common/code-help/create-user/create-user-java.js
  • frontend/common/code-help/create-user/create-user-node.js
  • frontend/common/code-help/create-user/create-user-php.js
  • frontend/common/code-help/create-user/create-user-ruby.js
  • frontend/common/code-help/create-user/create-user-rust.js
  • frontend/common/code-help/traits/traits-java.js
  • frontend/common/code-help/traits/traits-node.js
  • frontend/common/code-help/traits/traits-php.js
  • frontend/common/code-help/traits/traits-ruby.js
  • frontend/common/code-help/traits/traits-rust.js

📝 Walkthrough

Walkthrough

The generated iOS, Java, PHP, Ruby, and Rust templates now emit optional custom Flagsmith URL configuration only when enabled, avoiding interpolated boolean values. Node templates switch from default to named Flagsmith imports. The Rust create-user generator also reformats its exported function signature. Changes apply to both create-user and traits code generators.

Estimated code review effort: 2 (Simple) | ~10 minutes


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-8146 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api-test:pr-8146 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api:pr-8146 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-8146 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-8146 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-frontend:pr-8146 Finished ✅ Results

Comment thread frontend/common/code-help/create-user/create-user-ios.js
Comment thread frontend/common/code-help/create-user/create-user-java.js
@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor
✅ private-cloud · depot-ubuntu-latest-16 — run #18812 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  58.8 seconds
commit  b437d63
info  🔄 Run: #18812 (attempt 1)

🗂️ Previous results
✅ private-cloud · depot-ubuntu-latest-arm-16 — run #18812 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  36.6 seconds
commit  b437d63
info  🔄 Run: #18812 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #18812 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  45.6 seconds
commit  b437d63
info  🔄 Run: #18812 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #18812 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  40.3 seconds
commit  b437d63
info  🔄 Run: #18812 (attempt 1)

Comment thread frontend/common/code-help/traits/traits-node.js
@github-actions

Copy link
Copy Markdown
Contributor

Visual Regression

19 screenshots compared. See report for details.
View full report

@kyle-ssg
kyle-ssg merged commit 4d32782 into main Jul 29, 2026
30 checks passed
@kyle-ssg
kyle-ssg deleted the fix/code-help-traits-snippets branch July 29, 2026 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants