Skip to content

fix(adapters/linear): default a token without expires_in to 30 days - #131

Merged
ThomasK33 merged 3 commits into
mainfrom
fix/linear-token-default-lifetime
Oct 29, 2026
Merged

ThomasK33 merged 3 commits into
mainfrom
fix/linear-token-default-lifetime

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

Why

The operator goal is one small, reviewed PR for every open follow-up issue in coder/chat. This PR closes the token-lifetime issue in adapters/linear.

When Linear's client-credentials token response has no positive expires_in, the adapter sets no expiry and keeps the token until the process restarts. After Linear expires the token, every call fails. Linear's OAuth docs give these tokens a 30-day lifetime, and RFC 6749 section 5.1 makes expires_in optional.

What changed

  • exchangeClientCredentials sets the expiry to 30 days when expires_in is missing or not positive. The existing 1-hour refresh buffer then refreshes the token.
  • ensureToken and tenantToken no longer treat a zero expiry as "never expires". No code path sets a zero expiry now.
  • The token contract in adapters/linear/README.md describes the new behavior.

Scope

  • The fix covers the single-install token and the cached per-tenant tokens.
  • It does not add a refresh after a 401. That path is a larger change.

Blast Radius

The change affects only token responses without a positive expires_in. Responses with expires_in keep their exact expiry.

Verification

  • The first commit adds TestSingleInstallRefreshesTokenWithoutExpiresIn and TestMultiTenantRefreshesTokenWithoutExpiresIn. They fail on that commit with "token requests past 30 days minus refresh buffer = 1, want 2". They pass after the fix. Each test checks that the adapter reuses the token 1 minute before the refresh point and fetches a new one 1 minute after it.
  • go vet, go test for the root, adapter, state, and example modules, go test -race ./adapters/linear/..., and gofmt -l . pass.

Closes #126


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

… days

Both the single-install and the multi-tenant path keep a client-credentials
token forever when the token response has no expires_in. These tests advance
the adapter clock past 30 days minus the 1-hour refresh buffer and expect a
new token request. They fail on this commit.
When the client-credentials response has no positive expires_in, set the
expiry to Linear's documented 30-day lifetime. The existing 1-hour refresh
buffer then refreshes the token before Linear expires it. Before this, the
expiry was the zero time and both ensureToken and tenantToken kept the token
until the process restarted. The zero-expiry branches in both checks are now
unreachable, so they are removed.

Update the README token contract to match.
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T20:51:56.008287Z 81cf500 Manual request
🔒 Security Review ✅ Completed 2026-10-29T20:52:26.406461Z 81cf500 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 81cf500d18

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 81cf500d18

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@ThomasK33
ThomasK33 merged commit 88b10bd into main Oct 29, 2026
2 checks passed
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.

adapters/linear: a token response without expires_in is never refreshed

1 participant