Skip to content

Fixing issue #830#837

Merged
samaybar merged 3 commits intorailwayapp:masterfrom
bliu8923:postgres-auth-fix
Apr 16, 2026
Merged

Fixing issue #830#837
samaybar merged 3 commits intorailwayapp:masterfrom
bliu8923:postgres-auth-fix

Conversation

@bliu8923
Copy link
Copy Markdown
Contributor

@bliu8923 bliu8923 commented Apr 10, 2026

Use unauthenticated GraphQL client for public template metadata lookups

Description

Summary

This PR separates public template metadata reads from authenticated project operations by introducing a dedicated public GraphQL client path.

  • Added GQLClient::new_public() for requests that should not include auth headers.
  • Refactored client construction via a shared build_client() helper.
  • Updated template metadata fetches to use the public client in:
    • deploy flow (fetch_and_create)
    • MCP deploy_template
    • MCP search_templates
  • Kept authenticated client usage for template deployment mutations and other project-scoped actions.

Why

Template listing/detail endpoints are public and do not require user/project credentials. Sending auth headers to those calls is unnecessary and increases token exposure risk. This change aligns with least-privilege behavior by only attaching credentials where required.

Testing

  • Added unit/integration-style test in src/client.rs:
    • public_client_can_query_templates_without_auth_headers
    • Spins up a local TCP HTTP server, captures the request, and asserts no authorization header is sent.
    • Verifies the GraphQL response is parsed successfully (id, name, and serializedConfig handling).

Manual verification (recommended)

  • Run template deploy flow and confirm template detail fetch succeeds without auth header regressions.
  • Run MCP search_templates and deploy_template to confirm public lookup + authenticated deploy behavior remains correct.

@bliu8923 bliu8923 marked this pull request as draft April 10, 2026 11:08
Railway template lookup endpoints reject authenticated requests, so use a public GraphQL client for template detail and template search requests. Add a regression test so add --database keeps working for logged-in users.
Keep the postgres auth fix focused by removing the stray npm lockfile and the unrelated API token handling change from this PR.
@brody192
Copy link
Copy Markdown
Collaborator

Hello, thank you for the PR. Could you update your description to include the original issue with the code and how your changes fix it?

@bliu8923 bliu8923 marked this pull request as ready for review April 10, 2026 23:07
@bliu8923
Copy link
Copy Markdown
Contributor Author

Hey @brody192 just did, feel free to take a look. Not a very big open source/Rust dev so open to any input!

@samaybar samaybar added the release/patch Author patch release label Apr 16, 2026
@samaybar samaybar merged commit 991d8f0 into railwayapp:master Apr 16, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release/patch Author patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants