Skip to content

fix(credential-groups): raise OAuth code cap so Atlassian callbacks validate - #7422

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/credential-group-oauth-code-cap
Sep 2, 2026
Merged

fix(credential-groups): raise OAuth code cap so Atlassian callbacks validate#7422
waleedlatif1 merged 2 commits into
stagingfrom
fix/credential-group-oauth-code-cap

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • The managed credential-group OAuth callback capped the code query param at 2048 characters, so providers that return a signed JWT as their authorization code (Atlassian's Confluence/Jira among them) failed validation before the token exchange ran.
  • That bound dates from when the flow only supported Slack, whose codes are short. It was never revisited as more OAuth providers were added to credential groups.
  • Shared a single MAX_OAUTH_CODE_LENGTH (8192) from the contract primitives and used it on both callback paths. oauth-connections.ts already used 8192 for the same field via its own private literal; the two contracts had drifted, and this collapses them onto one constant so they can't again.
  • Only the credential-group enrollment path was affected. Ordinary OAuth connections fork to Better Auth earlier in the shared callback and never hit this schema, which is why the bug went unnoticed.

Type of Change

  • Bug fix

Testing

Tested manually. Added two contract tests: a JWT-sized code now parses, and a code past the new bound is still rejected. Verified the first test fails against the old 2048 cap and passes with the fix.

bun run lint, bun run check:audits (45 audits), and check:api-validation:strict all pass.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

🤖 Generated with Claude Code

https://claude.ai/code/session_013e5sXbYST2R4qNzM996GFg

…alidate

The managed credential-group callback capped the OAuth `code` query param at
2048 characters. That bound was sized when the flow only supported Slack, whose
authorization codes are short, and was never revisited as more providers were
added. Providers that return a signed JWT as the authorization code exceed it,
so the callback rejected the exchange with a validation error before it ran.

Share a single MAX_OAUTH_CODE_LENGTH (8192) from the contract primitives and use
it on both callback paths, so the two contracts cannot drift apart again.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013e5sXbYST2R4qNzM996GFg
@vercel

vercel Bot commented Sep 2, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 2, 2026 10:46pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR raises the credential-group OAuth authorization-code limit to 8192 characters and centralizes that limit for the two bounded callback contracts.

  • Adds a shared MAX_OAUTH_CODE_LENGTH contract primitive.
  • Applies the shared bound to credential-group and ordinary OAuth callback schemas.
  • Adds tests covering a 4096-character code and rejection beyond the new bound.
  • Removes the inaccurate claim that every callback contract adopts this bound.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/lib/api/contracts/primitives.ts Defines the shared 8192-character OAuth code bound and fixes the previously overstated adoption comment.
apps/sim/lib/api/contracts/credential-groups.ts Replaces the credential-group callback’s 2048-character cap with the shared 8192-character limit.
apps/sim/lib/api/contracts/oauth-connections.ts Reuses the shared OAuth code bound instead of a private equivalent constant.
apps/sim/lib/api/contracts/credential-groups.test.ts Adds positive and boundary-rejection coverage for the raised callback-code limit.

Reviews (2): Last reviewed commit: "fix(credential-groups): correct the OAut..." | Re-trigger Greptile

Comment thread apps/sim/lib/api/contracts/primitives.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

The constant's comment claimed every callback contract shares the bound, but the
Shopify and MCP callback schemas leave `code` unbounded. Describe what the bound
is and why it is sized as it is, without asserting an adoption scope that would
go stale as contracts are migrated onto it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013e5sXbYST2R4qNzM996GFg
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit f050dc0 into staging Sep 2, 2026
23 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/credential-group-oauth-code-cap branch September 2, 2026 22:49
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