Skip to content

Use user GitHub OAuth token for repochecker API calls - #203

Merged
Apollon77 merged 13 commits into
mainfrom
copilot/fix-403-error-setting-stable
Oct 13, 2026
Merged

Apollon77 merged 13 commits into
mainfrom
copilot/fix-403-error-setting-stable

Conversation

Copilot AI commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

SET AS STABLE could fail with a GitHub API 403. The repochecker made unauthenticated requests and ran into the shared limit of 60 requests per hour. With this change, checks run with the logged-in user's GitHub token, so they get authenticated rate limits.

  • Backend /api/repochecker/
    • Reads the user's token from the existing gh-token session cookie, the same way /api/user/ does, and passes it as queryStringParameters.githubToken. That parameter is supported by @iobroker/repochecker ≥ 5.21.0; the backend uses 5.22.4.
    • Requires login: a request without the cookie gets 401.
    • Concurrency: one check runs at a time and up to 10 more wait in a queue. When the queue is full, new requests get 429. Each user can have only one check running or queued at a time; a second one also gets 429.
    • Errors return a generic 500 without the error details or the token.
  • Frontend: no changes. The cookie is sent automatically, and both places that run a check already require a logged-in user.
  • Tests: npm test in express/backend (node:test) covers passing the token, the login requirement, the per-user limit, the queue and its cap, and error redaction.

Why only one check at a time: repochecker still keeps a module-level Axios instance and log redaction state in lib/common.js. Parallel checks could therefore use another user's token or log it unredacted. This is tracked upstream in ioBroker/ioBroker.repochecker#1193. A TODO at MAX_PARALLEL_CHECKS says to raise the limit to 3 once that is fixed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BSR3invYVCrhJk7Swpp9qn

Co-authored-by: Apollon77 <11976694+Apollon77@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix 403 rate limit errors on unauthenticated API requests Use user GitHub OAuth token for repochecker API calls Sep 2, 2026
Copilot AI requested a review from Apollon77 September 2, 2026 15:06
@Apollon77
Apollon77 requested a balanced review from Copilot September 2, 2026 15:07
@Apollon77
Apollon77 marked this pull request as ready for review September 2, 2026 15:08

Copilot AI 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.

🟡 Changes recommended

The installed repochecker version ignores the forwarded header, leaving GitHub requests unauthenticated.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Attempts to authenticate repochecker GitHub API calls with the logged-in user’s OAuth token.

Changes:

  • Passes the token from both frontend check flows.
  • Adds the token as an authorization header.
  • Forwards and types the header in the backend.
File summaries
File Description
express/frontend/src/tools/AdapterCheck.tsx Passes the user token.
express/frontend/src/tools/adapter/releases/UpdateRepositoriesDialog.tsx Passes the token during releases.
express/frontend/src/lib/ioBroker.ts Adds the authorization header.
express/backend/src/api/repochecker.ts Forwards the header to repochecker.
express/backend/src/@types/iobroker__repochecker/index.d.ts Extends request typing.
Review details
  • Files reviewed: 4/5 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread express/backend/src/api/repochecker.ts Outdated
Copilot AI and others added 3 commits September 2, 2026 15:26
Co-authored-by: Apollon77 <11976694+Apollon77@users.noreply.github.com>
Co-authored-by: Apollon77 <11976694+Apollon77@users.noreply.github.com>
Co-authored-by: Apollon77 <11976694+Apollon77@users.noreply.github.com>

Copilot AI 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.

🟡 Changes recommended

IPC results can be dropped and unbounded worker creation creates a resource-exhaustion risk.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 3
  • Review effort level: Balanced

Comment thread express/backend/src/api/repochecker-worker.js Outdated
Comment thread express/backend/src/api/repochecker.ts Outdated
Comment thread express/backend/src/api/repochecker.ts Outdated
@Apollon77

Copy link
Copy Markdown
Collaborator

Ok, STOP here, we go to draft ... the env variable will not work here ... I do not like to fork that many processes ... We should adjust the repo checker library that we get this as a lib parameter

@Apollon77
Apollon77 marked this pull request as draft September 2, 2026 15:55
@UncleSamSwiss

Copy link
Copy Markdown
Collaborator

on hold: waiting for changes to repochecker according to @Apollon77

@mcm1957

mcm1957 commented Sep 5, 2026

Copy link
Copy Markdown

@Apollon77 @UncleSamSwiss

Repochecker 5.21.0 accepts a new paramater githubToken. If request.queryStringParameters.githubToken is set this string will be used as github token to authenticate for axios calls. The token will NOT be loaded into the environment but only store within code.

Feel free to test.

@Apollon77

Copy link
Copy Markdown
Collaborator

@copilot Update the PR and use the new parameter in the

Repochecker 5.21.0 accepts a new paramater githubToken. If request.queryStringParameters.githubToken is set this string will be used as github token to authenticate for axios calls. The token will NOT be loaded into the environment but only store within code.

Co-authored-by: Apollon77 <11976694+Apollon77@users.noreply.github.com>

Copilot AI 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.

🟢 Approval recommended

The authenticated token flow is correctly wired and tested; the only finding is a non-blocking stale version reference.

1 open finding
3 resolved since last review
Files not reviewed (1)
  • express/backend/package-lock.json: Generated file

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Comment thread express/backend/src/api/repochecker.ts Outdated

@UncleSamSwiss UncleSamSwiss left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks a lot for the PR!
The I would change to simply use the cookie that is already in every request (see attached screenshot in the second comment).
See also my first comment about the (IMHO) overly restrictive access check (i.e. single repo check at any time).

Comment thread express/backend/src/api/repochecker.ts Outdated
Comment thread express/backend/src/api/repochecker.ts Outdated
Comment thread express/frontend/src/lib/ioBroker.ts Outdated
@mcm1957

mcm1957 commented Oct 10, 2026

Copy link
Copy Markdown

@Apollon77 @UncleSamSwiss

Any reason to wait?
Something needs a fix?

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@Apollon77 Apollon77 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot Address the comments

Comment thread express/backend/src/api/repochecker.ts Outdated
Comment thread express/backend/src/api/repochecker.ts Outdated
Comment thread express/frontend/src/lib/ioBroker.ts Outdated
…checks

- Use the existing gh-token cookie instead of a separate Authorization
  header; revert the frontend changes that sent the token explicitly.
- Replace the global single-check lock (503) with a small queue that runs
  up to 3 checks in parallel, plus one in-flight check per user (429).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BSR3invYVCrhJk7Swpp9qn

Copilot AI 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.

🟡 Changes recommended

Parallel execution can mix user credentials upstream, and the public queue is unbounded.

1 open finding
1 resolved since last review
Files not reviewed (1)
  • express/backend/package-lock.json: Generated file

🧠 Review effort: Balanced

Comment thread express/backend/src/api/repochecker.ts
Requests without the gh-token cookie now get 401. Both frontend flows
already require a logged-in user, so the UI is unaffected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BSR3invYVCrhJk7Swpp9qn
@Apollon77
Apollon77 requested a balanced review from Copilot and removed request for Apollon77 October 13, 2026 06:59

Copilot AI 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.

🟡 Changes recommended

Client-controlled cookies bypass authentication, and parallel checks can use another user's OAuth token through repochecker's shared Axios state.

1 open finding
1 resolved since last review
Files not reviewed (1)
  • express/backend/package-lock.json: Generated file

🧠 Review effort: Balanced

Comment thread express/backend/src/api/repochecker.ts Outdated
repochecker still shares a module-level Axios instance and redaction
state between checks, so parallel checks could use or log another
user's token. Checks are queued instead of rejected; raise the limit
once ioBroker/ioBroker.repochecker#1193 is fixed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BSR3invYVCrhJk7Swpp9qn

Copilot AI 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.

🟡 Changes recommended

A stalled repochecker request can permanently occupy the sole execution slot and disable subsequent checks.

1 open finding
1 resolved since last review
Files not reviewed (1)
  • express/backend/package-lock.json: Generated file

🧠 Review effort: Balanced

Comment on lines +50 to +52
function runRepochecker(request: CheckRequest): Promise<CheckResult> {
return new Promise((resolve, reject) => {
handler(request, null, (error, result) => {

Copilot AI 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.

🔵 Needs a closer look

A stalled repochecker request can permanently occupy the sole execution slot and disable the endpoint.

1 open finding
Files not reviewed (1)
  • express/backend/package-lock.json: Generated file

🧠 Review effort: Balanced

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.

[Bug] Unauthenticated GitHub API requests cause 403 Rate Limit errors when clicking "SET AS STABLE"

6 participants