Skip to content

fix: validate PDS_INTERNAL_URL has http(s) scheme before use#23

Open
aspiers wants to merge 1 commit intomainfrom
fix/validate-pds-internal-url-scheme
Open

fix: validate PDS_INTERNAL_URL has http(s) scheme before use#23
aspiers wants to merge 1 commit intomainfrom
fix/validate-pds-internal-url-scheme

Conversation

@aspiers
Copy link
Contributor

@aspiers aspiers commented Mar 14, 2026

Summary

  • Adds ensurePdsUrl() helper that validates the URL includes an http:// or https:// scheme, failing fast with a clear error message instead of a cryptic TypeError: Failed to parse URL deep inside fetch()
  • Updates all 6 call sites reading PDS_INTERNAL_URL in auth-service to use the new helper

Context

In Railway prod, PDS_INTERNAL_URL was set to a bare hostname without a scheme (certified-apppds-core.railway.internal), causing:

TypeError: Failed to parse URL from certified-apppds-core.railway.internal/_internal/ping-request?request_uri=...
caused by: TypeError: Invalid URL

With this fix the service will instead throw at startup (or first use for lazy call sites):

PDS_INTERNAL_URL is missing the http:// or https:// scheme: "certified-apppds-core.railway.internal"

@vercel
Copy link

vercel bot commented Mar 14, 2026

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

Project Deployment Actions Updated (UTC)
epds-demo Ready Ready Preview, Comment Mar 14, 2026 7:42pm

Request Review

@coderabbitai
Copy link

coderabbitai bot commented Mar 14, 2026

Warning

Rate limit exceeded

@aspiers has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 54 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 18bcd26d-dd34-4e66-b828-e8c54c13f1ba

📥 Commits

Reviewing files that changed from the base of the PR and between 75b94de and 61db980.

📒 Files selected for processing (7)
  • packages/auth-service/src/better-auth.ts
  • packages/auth-service/src/lib/auto-provision.ts
  • packages/auth-service/src/lib/pds-url.ts
  • packages/auth-service/src/routes/account-settings.ts
  • packages/auth-service/src/routes/choose-handle.ts
  • packages/auth-service/src/routes/complete.ts
  • packages/auth-service/src/routes/login-page.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/validate-pds-internal-url-scheme
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

All 6 call sites reading PDS_INTERNAL_URL now go through ensurePdsUrl(),
which fails fast with a clear error when the URL is missing its scheme.
Previously a bare hostname (e.g. 'host.railway.internal') silently
produced an invalid URL that only surfaced as a cryptic
'TypeError: Failed to parse URL' inside fetch().
@coveralls-official
Copy link

Pull Request Test Coverage Report for Build 23094976254

Details

  • 0 of 16 (0.0%) changed or added relevant lines in 7 files are covered.
  • 2 unchanged lines in 2 files lost coverage.
  • Overall coverage remained the same at 27.05%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/auth-service/src/better-auth.ts 0 1 0.0%
packages/auth-service/src/lib/auto-provision.ts 0 1 0.0%
packages/auth-service/src/routes/account-settings.ts 0 1 0.0%
packages/auth-service/src/routes/login-page.ts 0 1 0.0%
packages/auth-service/src/routes/choose-handle.ts 0 3 0.0%
packages/auth-service/src/routes/complete.ts 0 3 0.0%
packages/auth-service/src/lib/pds-url.ts 0 6 0.0%
Files with Coverage Reduction New Missed Lines %
packages/auth-service/src/routes/account-settings.ts 1 0.0%
packages/auth-service/src/routes/login-page.ts 1 0.0%
Totals Coverage Status
Change from base Build 23094915933: 0.0%
Covered Lines: 464
Relevant Lines: 1577

💛 - Coveralls

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