Skip to content

fix(importer): skip the embed launcher for missing or blank client IDs - #209

Merged
behnam-oneschema merged 1 commit into
mainfrom
devin/1792435265-blank-client-id
Oct 19, 2026
Merged

behnam-oneschema merged 1 commit into
mainfrom
devin/1792435265-blank-client-id

Conversation

@behnam-oneschema

Copy link
Copy Markdown
Member

Summary

OneSchemaImporterClass built the iframe URL as embed_client_id=${clientId}. An integration that mounts the importer before its config has loaded therefore loaded /embed-launcher?embed_client_id= (or =undefined) and showed the error page. In prod this comes to roughly 5k blank launches a day from one customer on @oneschema/react 0.7.1, repeating every few seconds.

Behavior change, when clientId is missing, not a string, or blank after trim:

constructor / iframe setup:  never sets iframe.src; console.error(INVALID_CLIENT_ID_MESSAGE)
launch() / launchSession():  reject with OneSchemaLaunchFailure(error: OneSchemaLaunchError.InvalidClientId)
                             and emit `launched` { success: false, error: InvalidClientId }

INVALID_CLIENT_ID_MESSAGE is "OneSchema config error: clientId must be a non-empty string".

  • OneSchemaLaunchError.InvalidClientId is a new enum member. None of the existing codes fit: MissingJwt, MissingTemplate and MissingSessionToken each name a different parameter. It is appended after Cancelled, so the numeric values of the existing members don't change. It is documented in the enum JSDoc and in the synchronous-rejection list in packages/importer/LAUNCH-SEQUENCE.md. main already carries unreleased major changesets, so a new member is fine here.
  • A valid client ID is now encodeURIComponent-ed in the launcher URL. For plain IDs such as client-id the URL doesn't change.
  • Changeset: .changeset/blank-client-id.md (@oneschema/importer patch).

Testing

  • yarn build: passes.
  • yarn check: passes after yarn build. There are 0 errors and one existing ESLint warning in filefeeds-react.
  • yarn workspace @oneschema/importer test:ci: 42/42 pass. The new tests:
    • A clientId of "", whitespace, undefined or 123 sets no iframe src.
    • launch() and launchSession() reject with InvalidClientId and emit the launched failure event.
    • Construction without a client ID appends no iframe.
    • Client IDs are URL-encoded.
  • React: @oneschema/react has no automated test harness. Its test:ci is true, and test/ holds only a manual Parcel page, so this PR adds no <OneSchemaImporter clientId=""> test there.
  • Angular TS2307 under yarn check: this is a build-order issue, not something this PR introduced. On a clean origin/main, yarn check without a prior build fails the same way (@oneschema/importer not found, then cascading OneSchemaService errors), and it passes after yarn build. CI already runs "Build packages" before "Check packages".

Link to Devin session: https://app.devin.ai/sessions/8e97956405544cdb86cfaa00c37b94ca
Open in Devin Desktop: https://app.devin.ai/desktop/session/8e97956405544cdb86cfaa00c37b94ca?variant=devin
Requested by: @behnam-oneschema

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Team
  • Run ID: 479f3335-6a2f-4d84-80b3-1500d3e7e653
📥 Commits

Reviewing files that changed from the base of the PR and between 5ffbd2c and 81b401c.

📒 Files selected for processing: 5
  • .changeset/blank-client-id.md
  • packages/importer/LAUNCH-SEQUENCE.md
  • packages/importer/src/config.ts
  • packages/importer/src/importer.ts
  • packages/importer/test/importer.test.cjs

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Walkthrough

The importer validates client IDs before iframe setup and launch. Invalid IDs produce InvalidClientId errors. Valid IDs are URL-encoded in the embed launcher URL.

Changes

Client ID validation and launch

Layer / File(s) Summary
Validate client IDs and reject invalid launches
packages/importer/src/config.ts, packages/importer/src/importer.ts, packages/importer/test/importer.test.cjs, packages/importer/LAUNCH-SEQUENCE.md, .changeset/blank-client-id.md
The importer adds OneSchemaLaunchError.InvalidClientId and validates client IDs before iframe setup and launch. Tests cover missing, non-string, and blank IDs, including failed launch status events. The launch documentation and changeset record this behavior.
Encode client IDs in launcher URLs
packages/importer/src/importer.ts, packages/importer/test/importer.test.cjs
The importer URL-encodes clientId in the launcher URL. Tests cover spaces and slashes and confirm the default ID remains unchanged.

Priority: ⬇️ Low

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

Change: Bug fix

Suggested reviewers: ryapapap

Merge Risk: ⚪ Minimal · up to 81b40

No merge-blocking issue was identified; the change is ready to merge after normal checks.

Pre-merge checks: Passed 6
Check name Status Explanation
Title check Passed The title uses the required Conventional Commits format and accurately describes the importer change for missing or blank client IDs.
Description check Passed The description clearly explains the client ID validation behavior, error handling, URL encoding, tests, and build results. It is directly related to the changeset.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Security Check Passed No security concern was introduced. The changed URL construction now applies encodeURIComponent to clientId, which prevents query-parameter injection through values such as &, =, or #. Inval…
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3 files. (2 skipped: 2 unsupported.)

Full details: Security Check

Explanation

No security concern was introduced. The changed URL construction now applies encodeURIComponent to clientId, which prevents query-parameter injection through values such as &amp;, =, or #. Invalid client IDs are rejected before iframe creation or launch, and the new error message contains no user-controlled value. Existing postMessage origin and source checks remain in place.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions

Copy link
Copy Markdown
Contributor

Bundle size report

Package/file Gzip size Raw size Delta vs base (gzip)
@oneschema/angular/esm2022/base-index.mjs 553 B 700 B 0 B (0.00%)
@oneschema/angular/esm2022/oneschema-angular.mjs 421 B 512 B 0 B (0.00%)
@oneschema/angular/esm2022/src/lib/oneschema.button.mjs 1,759 B 3,194 B 0 B (0.00%)
@oneschema/angular/esm2022/src/lib/oneschema.module.mjs 1,459 B 3,363 B 0 B (0.00%)
@oneschema/angular/esm2022/src/lib/oneschema.params.mjs 603 B 848 B 0 B (0.00%)
@oneschema/angular/esm2022/src/lib/oneschema.service.mjs 1,544 B 3,189 B 0 B (0.00%)
@oneschema/angular/esm2022/src/public-api.mjs 517 B 761 B 0 B (0.00%)
@oneschema/angular/fesm2022/oneschema-angular.mjs 1,551 B 5,217 B 0 B (0.00%)
@oneschema/filefeeds-react/main.js 7,857 B 35,825 B 0 B (0.00%)
@oneschema/filefeeds-react/module.js 7,730 B 35,424 B 0 B (0.00%)
@oneschema/filefeeds-react/module.mjs 7,731 B 35,425 B 0 B (0.00%)
@oneschema/filefeeds/main.js 6,694 B 29,909 B 0 B (0.00%)
@oneschema/filefeeds/module.js 6,647 B 29,774 B 0 B (0.00%)
@oneschema/filefeeds/module.mjs 6,648 B 29,775 B 0 B (0.00%)
@oneschema/filefeeds/oneschema-filefeeds-0.5.3.min.js 3,278 B 9,350 B 0 B (0.00%)
@oneschema/filefeeds/oneschema-filefeeds-0.5.latest.min.js 3,282 B 9,355 B 0 B (0.00%)
@oneschema/importer/main.js 12,081 B 60,461 B +213 B (1.79%)
@oneschema/importer/module.js 12,026 B 60,170 B +215 B (1.82%)
@oneschema/importer/module.mjs 12,027 B 60,171 B +215 B (1.82%)
@oneschema/importer/oneschema-importer-0.7.7.min.js 5,514 B 16,999 B +100 B (1.85%)
@oneschema/importer/oneschema-importer-0.7.latest.min.js 5,518 B 17,004 B +100 B (1.85%)
@oneschema/react/main.js 15,070 B 70,917 B +213 B (1.43%)
@oneschema/react/module.js 14,958 B 70,305 B +212 B (1.44%)
@oneschema/react/module.mjs 14,959 B 70,306 B +212 B (1.44%)
@oneschema/vue/main.js 30,567 B 135,248 B +200 B (0.66%)
@oneschema/vue/module.js 30,514 B 135,117 B +201 B (0.66%)
@oneschema/vue/module.mjs 30,515 B 135,118 B +201 B (0.66%)

@behnam-oneschema
behnam-oneschema marked this pull request as ready for review October 19, 2026 19:04
@behnam-oneschema
behnam-oneschema merged commit b4c7f2b into main Oct 19, 2026
4 checks passed
@behnam-oneschema
behnam-oneschema deleted the devin/1792435265-blank-client-id branch October 19, 2026 22:43
behnam-oneschema added a commit that referenced this pull request Oct 19, 2026
…s (0.7.8 backport) (#210)

## Summary

This backports #209 to the new `release/0.7` maintenance line as
`@oneschema/importer` 0.7.8. It also adds the release plumbing that
publishes that line under the npm dist-tag `release-0.7`, so `latest`
never moves. `release/0.7` was cut from
`9eaa44a0b42a8c9fbe8561a83384b554aabf5037` (`Version Packages (#188)`).
All four `@oneschema/{importer,react,vue,angular}@0.7.7` tags point at
that commit.

### Fix, adapted to the 0.7.7 synchronous API (no new public API or enum
members)

```ts
// setIframe(), after the destroyed check
if (!this.#hasValidClientId()) { console.error(INVALID_CLIENT_ID_MESSAGE); return }  // iframe src never set
queryParams.push(`embed_client_id=${encodeURIComponent(this.#params.clientId)}`)

// launch(), after _hasAttemptedLaunch = true; launchSession() delegates here
// emits "launched" with, and returns, the same shape as the MissingJwt/MissingTemplate failures:
{ success: false, error: OneSchemaLaunchError.LaunchError, message: INVALID_CLIENT_ID_MESSAGE }
```

- A client ID is invalid when it is missing, not a string, or blank
after trimming. The message is `"OneSchema config error: clientId must
be a non-empty string"`.
- The existing generic `LaunchError` code is used because main's
`InvalidClientId` is a new enum member and can't ship in a patch.

### Maintenance release plumbing (this branch only; main's `release.yml`
is untouched)

- `.changeset/config.json`: `baseBranch: "release/0.7"`.
- `package.json`: the `release` script runs `changeset publish --tag
release-0.7`.
- `release.yml`: triggers on push to `release/0.7`. The Changesets
action gets `branch: release/0.7` and title/commit `Version Packages
(release/0.7)`, so the version PR targets `release/0.7` from
`changeset-release/release/0.7`, which can't collide with main's
`changeset-release/main`. The read-only `verify` job, the `release`
environment, OIDC trusted publishing, pinned actions, tag checks and
`verify-published.mjs` (which packs `name@version`, not a dist-tag) are
unchanged.

### How maintenance releases work (also in
`CONTRIBUTING.md#maintenance-releases`; README updated)

1. `release/<major>.<minor>` is cut from that line's last release
commit.
2. Fixes land through PRs into it, each with a patch changeset.
3. A push opens `Version Packages (release/0.7)`. Merging that PR
publishes under `release-0.7`.
4. `^0.7.x` ranges resolve to the newest 0.7 patch by semver.
`@oneschema/react@0.7.1` depends on `@oneschema/importer@^0.7.0`, so it
picks up 0.7.8 on a fresh resolve or `npm update`.

## Repo-admin steps (Behnam)

- [x] Add `release/0.7` to the `release` environment's deployment-branch
policy. (API confirms the policies are now `main` and `release/0.7`.)
- [x] Add branch protection for `release/0.7`. (`protect-main` ruleset
now also includes `refs/heads/release/*`; API confirms `release/0.7`
gets deletion, non-fast-forward, linear history, pull request and
required status check rules.)
- [x] Confirm npm trusted publishing for all four packages accepts
`release.yml` + environment `release` when it runs from `release/0.7`.
(npm's trusted-publisher settings have no branch field; the first real
check is the first `release/0.7` publish.)

## Notes

- `yarn changeset status --verbose` plans **only `@oneschema/importer`
0.7.8**. With this config the linked group does not bump the wrappers.
React, Vue and Angular stay at 0.7.7, and their `^0.7.7` importer range
already admits 0.7.8. I didn't add wrapper changesets.
- Unverified: the Changesets action also creates GitHub Releases, and
GitHub may mark a 0.7.x release as the repo's "Latest" release after 1.0
ships. This does not affect npm's `latest` tag.

## Testing

- `yarn build`, `yarn check` (0 errors; one pre-existing ESLint warning
in `filefeeds-react`), `yarn test:ci` (importer 9/9), `yarn
check:ranges`, `yarn check:install`, `actionlint`.
- New importer tests cover `""`, whitespace, `undefined` and `123` (no
src, no iframe, exact failure return and `launched` event,
`console.error`, no iframe message). They also cover managed-DOM
construction with no client ID (nothing appended), the unchanged default
URL, encoding `client id/one` → `client%20id%2Fone`, and
`launchSession()` returning the same failure.

Link to Devin session:
https://app.devin.ai/sessions/8e97956405544cdb86cfaa00c37b94ca
Open in Devin Desktop:
https://app.devin.ai/desktop/session/8e97956405544cdb86cfaa00c37b94ca?variant=devin
Requested by: @behnam-oneschema

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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