Skip to content

fix: list_my_todos/list_my_events honor GITLAB_TOKEN fallback (1.18.1)#39

Merged
ttpears merged 1 commit into
mainfrom
fix/me-tools-env-token-fallback
May 22, 2026
Merged

fix: list_my_todos/list_my_events honor GITLAB_TOKEN fallback (1.18.1)#39
ttpears merged 1 commit into
mainfrom
fix/me-tools-env-token-fallback

Conversation

@ttpears
Copy link
Copy Markdown
Owner

@ttpears ttpears commented May 22, 2026

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:

const credentials = input.userCredentials ? validateUserConfig(input.userCredentials) : userConfig;
if (!credentials) {
  throw new Error('list_my_todos requires user authentication — ...');
}

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)

  • 1.18.0: `list_my_todos requires user authentication — the to-do inbox is scoped to the caller`
  • This fix: returns the user's todos (validated against the live schema in the previous PR — schema-level fixes from 1.18.0 still apply)

Test plan

  • `npm run build` clean
  • Reproduced original failure against 1.18.0 in current session
  • CI green
  • After merge: re-test list_my_todos and list_my_events from the same client that was failing

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.
@ttpears ttpears merged commit 7a23cf3 into main May 22, 2026
2 checks passed
@ttpears ttpears deleted the fix/me-tools-env-token-fallback branch May 22, 2026 01:35
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