Skip to content

P0: fix(shared): safely fall back from malformed client IDs - #229

Open
aspiers wants to merge 1 commit into
mainfrom
split-pr165/safe-client-name-fallback
Open

P0: fix(shared): safely fall back from malformed client IDs#229
aspiers wants to merge 1 commit into
mainfrom
split-pr165/safe-client-name-fallback

Conversation

@aspiers

@aspiers aspiers commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Avoid presenting a malformed or non-HTTP client identifier as the application's visible name. Callers now fall back to neutral application copy when metadata cannot provide a trustworthy name.

Changes

  • Return no display name for malformed and unsupported client IDs
  • Retain safe hostname fallback for valid HTTP(S) identifiers
  • Add focused metadata tests and a changeset

Testing

  • pnpm format:check
  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm test:coverage

Screenshots

With client_id=my-local-app, the deployed page uses the generic browser title Sign in to an application instead of reflecting the malformed identifier.

Safe client-name fallback page

Notes

Summary by CodeRabbit

  • Bug Fixes
    • Sign-in pages no longer display malformed client IDs as application names.
    • Browser tab titles now use the generic “an application” label when app information cannot be resolved.
    • Invalid or unsupported client identifiers are handled with safer fallback metadata.

@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
epds-demo Ready Ready Preview Jul 30, 2026 3:56pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@aspiers, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 43 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 853be57b-15dc-482f-a7e1-a51da7080499

📥 Commits

Reviewing files that changed from the base of the PR and between b37db61 and 6f4fa2d.

📒 Files selected for processing (3)
  • .changeset/fallback-app-name-on-malformed-client-id.md
  • packages/shared/src/__tests__/client-metadata.test.ts
  • packages/shared/src/client-metadata.ts
📝 Walkthrough

Walkthrough

Malformed or non-HTTP client IDs no longer appear as application names. Metadata resolution returns empty metadata, callers use the generic “an application” fallback, and tests plus a changeset document the behavior.

Changes

Client ID fallback behavior

Layer / File(s) Summary
Metadata fallback and validation
packages/shared/src/client-metadata.ts, packages/shared/src/__tests__/client-metadata.test.ts, .changeset/fallback-app-name-on-malformed-client-id.md
Invalid or non-HTTP client IDs return empty metadata and resolve to “an application”; tests and the changeset capture the updated behavior.

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

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: safely falling back when malformed client IDs would otherwise surface as app names.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch split-pr165/safe-client-name-fallback

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.

@railway-app

railway-app Bot commented Jul 30, 2026

Copy link
Copy Markdown

🚅 Deployed to the ePDS-pr-229 environment in ePDS

Service Status Web Updated (UTC)
@certified-app/pds-core ✅ Success (View Logs) Web Jul 30, 2026 at 4:23 pm
@certified-app/auth-service ✅ Success (View Logs) Web Jul 30, 2026 at 4:23 pm
@certified-app/demo untrusted ✅ Success (View Logs) Web Jul 30, 2026 at 1:43 pm
@certified-app/demo ✅ Success (View Logs) Web Jul 30, 2026 at 1:43 pm

@changeset-bot

changeset-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6f4fa2d

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coveralls-official

coveralls-official Bot commented Jul 30, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 30559100622

Coverage increased (+0.1%) to 57.395%

Details

  • Coverage increased (+0.1%) from the base build.
  • Patch coverage: 3 of 3 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 3069
Covered Lines: 1755
Line Coverage: 57.18%
Relevant Branches: 1914
Covered Branches: 1105
Branch Coverage: 57.73%
Branches in Coverage %: Yes
Coverage Strength: 6.06 hits per line

💛 - Coveralls

@aspiers aspiers changed the title fix(shared): safely fall back from malformed client IDs P0: fix(shared): safely fall back from malformed client IDs Jul 30, 2026
@aspiers
aspiers marked this pull request as ready for review July 30, 2026 14:30
Copilot AI review requested due to automatic review settings July 30, 2026 14:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/shared/src/client-metadata.ts`:
- Around line 179-182: Update the domain fallback used by resolveClientName and
extractDomain so parseable non-HTTP(S) URLs such as ftp://example.com are
rejected before deriving a display name. Ensure resolveClientName falls back to
"an application" for these IDs, and add a regression test covering this
behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5fb6a161-c9e1-4f4a-9601-239604d6c81c

📥 Commits

Reviewing files that changed from the base of the PR and between 7bce175 and b37db61.

📒 Files selected for processing (3)
  • .changeset/fallback-app-name-on-malformed-client-id.md
  • packages/shared/src/__tests__/client-metadata.test.ts
  • packages/shared/src/client-metadata.ts

Comment thread packages/shared/src/client-metadata.ts
resolveClientMetadata returned `{ client_name: clientId }` when the
clientId failed to parse as a URL, or used a non-http(s) protocol.
The intent was probably "give the caller something to display" —
but the upshot was that a malformed query-string client_id ("Sign
in to not-a-url") or a schemeless one ("Sign in to javascript:…")
showed up verbatim in:

  - the auth-service login page <title> tag
  - the consent screen header
  - the OTP form's "Sign in to <appName>" heading

— effectively letting the URL bar shape user-visible text.

Return `{}` from those branches instead, so the caller's
fallback chain (`client_name || extractDomain(clientId) ||
'an application'`) ends in the static "an application" string.

Tests: two existing assertions on the leaky behaviour are
inverted to assert the fallback path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 30, 2026 15:55
@aspiers
aspiers force-pushed the split-pr165/safe-client-name-fallback branch from b37db61 to 6f4fa2d Compare July 30, 2026 15:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants