fix: list_my_todos/list_my_events honor GITLAB_TOKEN fallback (1.18.1)#39
Merged
Conversation
Both handlers had a guard that rejected the call when no per-request
userCredentials were supplied:
if (!credentials) {
throw new Error('... requires user authentication ...');
}
That short-circuited the four-step token resolution in getClient(),
which is supposed to fall back to GITLAB_TOKEN for stdio / single-user
deployments. The token is a real user's PAT and currentUser /
GET /events resolve from it fine — the handler just never let the
client method run.
Same bug class as 1.15.1, which fixed the equivalent guard on write
tools. The me-scoped read tools were missed at that time because they
were added later (list_my_todos in 1.16.0, list_my_events earlier).
Reproduced via stdio with GITLAB_TOKEN env set:
- 1.18.0: 'list_my_todos requires user authentication...'
- With this fix: returns the user's todos.
Per-call userCredentials and HTTP Authorization: Bearer flows continue
to work unchanged — credentials, when present, still take precedence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The actual blocker behind "list_my_todos still fails" wasn't the GraphQL shape (1.18.0 fixed the real schema bugs) — it was a handler-level guard:
That short-circuits the four-step token resolution in `getClient()`. With no per-call user credentials (e.g. stdio mode + `GITLAB_TOKEN` env), the handler throws before `getClient()` can fall back to the env token — even though that token is a real user's PAT and `currentUser` would resolve from it just fine.
Same bug class as 1.15.1 ("write tools honor GITLAB_TOKEN fallback"). That fix patched the write tools but missed these two me-scoped read tools — `list_my_todos` was added later in 1.16.0, `list_my_events` existed before but wasn't part of the 1.15.1 audit.
Fix: drop the guard from both handlers. Let `getClient()` decide. With no env token AND no per-call creds, the user gets a clean error from `getClient()` instead.
Reproduction (stdio, GITLAB_TOKEN set)
Test plan