Skip to content

servers: Don't use an auth token that expires within 1 second. #16459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 25, 2025

Conversation

danhsiung
Copy link
Collaborator

@danhsiung danhsiung commented Apr 25, 2025

WHY

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability of server-side authorized requests by refreshing authentication tokens up to 1 second before expiration.
  • Documentation

    • Updated changelog to reflect changes in version 1.5.4.

Copy link

vercel bot commented Apr 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Apr 25, 2025 11:02pm
pipedream-docs ⬜️ Ignored (Inspect) Apr 25, 2025 11:02pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Apr 25, 2025 11:02pm

@danhsiung danhsiung requested a review from jsendo April 25, 2025 22:37
Copy link
Contributor

coderabbitai bot commented Apr 25, 2025

Walkthrough

This update introduces a minor enhancement to the server-side OAuth token refresh logic within the SDK. The logic now triggers a token refresh if the token is set to expire within the next second, rather than waiting for it to fully expire. The changelog and package version have been updated to reflect this change, with no modifications to public APIs or exported entities.

Changes

File(s) Change Summary
packages/sdk/src/server/index.ts Adjusted OAuth token refresh logic to trigger if token expires within 1 second, not just at expiry.
packages/sdk/CHANGELOG.md Added changelog entry for version 1.5.4 describing the updated token refresh logic.
packages/sdk/package.json Updated package version from 1.5.3 to 1.5.4.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ServerSDK
    participant OAuthProvider

    Client->>ServerSDK: Make authorized request
    alt Token expires in >1s
        ServerSDK-->Client: Use existing token
    else Token expires in <=1s
        ServerSDK->>OAuthProvider: Refresh token
        OAuthProvider-->>ServerSDK: New token
        ServerSDK-->Client: Use refreshed token
    end
Loading

Poem

A token's life, so short and sweet,
Now gets a second's early treat.
Before it fades, we leap ahead,
Refresh in time, no errors dread.
With version bumped, the changelog sings—
A hop, a skip, for smoother things!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6ab18b0 and 3a363b8.

📒 Files selected for processing (1)
  • packages/sdk/CHANGELOG.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/sdk/CHANGELOG.md
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Lint Code Base
  • GitHub Check: test

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

jsendo
jsendo previously approved these changes Apr 25, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eda5597 and 7acb483.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • packages/sdk/CHANGELOG.md (1 hunks)
  • packages/sdk/package.json (1 hunks)
  • packages/sdk/src/server/index.ts (1 hunks)
🧰 Additional context used
🪛 GitHub Check: test
packages/sdk/CHANGELOG.md

[failure] 9-9: Line length
packages/sdk/CHANGELOG.md:9:81 MD013/line-length Line length [Expected: 80; Actual: 98] https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md013.md

🪛 GitHub Actions: Lint SDK Markdown Files
packages/sdk/CHANGELOG.md

[error] 9-9: markdownlint MD013/line-length: Line length exceeds 80 characters (Actual: 98).

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: test
  • GitHub Check: pnpm publish
  • GitHub Check: Lint Code Base
🔇 Additional comments (2)
packages/sdk/package.json (1)

4-4: Version bump looks good

The package version has been updated from 1.5.3 to 1.5.4, which is consistent with the changes in the CHANGELOG.md and the implementation.

packages/sdk/src/server/index.ts (1)

261-261: Excellent proactive token refresh improvement

The change to refresh the OAuth token when it's about to expire within 1 second (rather than waiting until it actually expires) is a good defensive programming practice. This helps prevent potential authorization failures that could occur if a request is made with a token that expires during the request processing.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7acb483 and 6ab18b0.

📒 Files selected for processing (1)
  • packages/sdk/CHANGELOG.md (1 hunks)
🧰 Additional context used
🪛 GitHub Check: test
packages/sdk/CHANGELOG.md

[failure] 9-9: Trailing spaces
packages/sdk/CHANGELOG.md:9:82 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1] https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md009.md


[failure] 9-9: Line length
packages/sdk/CHANGELOG.md:9:81 MD013/line-length Line length [Expected: 80; Actual: 82] https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md013.md


[failure] 10-10: Lists should be surrounded by blank lines
packages/sdk/CHANGELOG.md:10 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "within 1 second."] https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md032.md

🪛 GitHub Actions: Lint SDK Markdown Files
packages/sdk/CHANGELOG.md

[error] 9-9: markdownlint MD009/no-trailing-spaces: Trailing spaces found (Expected: 0 or 2; Actual: 1). See https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md009.md

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Lint Code Base
  • GitHub Check: test
  • GitHub Check: pnpm publish

@danhsiung danhsiung merged commit f1e8fef into master Apr 25, 2025
10 checks passed
@danhsiung danhsiung deleted the server-side-auth-headers-1s branch April 25, 2025 23:06
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