Skip to content

fix: expand "me" shorthand on GET /v1/agents/me/tap and /me/reputation#49

Merged
i8ramin merged 1 commit into
mainfrom
fix/agents-me-shorthand-tap-reputation
Jun 1, 2026
Merged

fix: expand "me" shorthand on GET /v1/agents/me/tap and /me/reputation#49
i8ramin merged 1 commit into
mainfrom
fix/agents-me-shorthand-tap-reputation

Conversation

@chocothebot

Copy link
Copy Markdown
Collaborator

Problem

Agents using the me shorthand on TAP sub-routes got AGENT_NOT_FOUND or REPUTATION_LOOKUP_FAILED: Agent not found because the literal string "me" was passed directly to the KV lookup.

The root GET /v1/agents/:id handler in index.tsx already expands me correctly, but the sub-routes (/tap and /reputation) did not.

Confirmed live:

GET /v1/agents/me/tap       → { error: "AGENT_NOT_FOUND" }
GET /v1/agents/me/reputation → { error: "REPUTATION_LOOKUP_FAILED", message: "Agent not found" }

Fix

getTAPAgentRoute (tap-routes.ts): if rawId === "me", call validateTAPAppAccess and use appAccess.agentId from the token.

getReputationRoute (tap-reputation-routes.ts): same approach — validateTAPAppAccess is already called for auth, so agentId is extracted from it when rawId === "me".

Both error cases handled:

  • No token → 401 UNAUTHORIZED
  • Token with no agent_id claim (app-level token) → 401 UNAUTHORIZED

Tests

8 regression tests added in fix-me-shorthand-2026-05-18.test.ts:

  • getTAPAgentRoute: expands me to token agent_id
  • getTAPAgentRoute: returns 401 when no token
  • getTAPAgentRoute: returns 401 when token has no agent_id
  • getTAPAgentRoute: non-me path unaffected
  • getReputationRoute: expands me to token agent_id
  • getReputationRoute: returns 401 when token has no agent_id
  • getReputationRoute: non-me path unaffected
  • getReputationRoute: returns 401 when no token

149 existing tests still passing.

🤖 Shipped by Choco (weekly improvement sprint, 2026-05-18)

Both getTAPAgentRoute and getReputationRoute passed the literal string
"me" to the KV lookup when agents used the /agents/me/... shorthand,
returning AGENT_NOT_FOUND instead of the agent's own profile.

Fix:
- getTAPAgentRoute: if rawId === "me", call validateTAPAppAccess and use
  appAccess.agentId (consistent with the existing /v1/agents/:id handler
  in index.tsx which already supports the "me" shorthand)
- getReputationRoute: same approach — validateTAPAppAccess is already
  called for auth; agentId is now extracted from it when rawId === "me"

Both error cases are handled:
  - No token → 401 UNAUTHORIZED
  - Token with no agent_id claim (app-level token) → 401 UNAUTHORIZED

8 regression tests added covering both routes, both error paths, and
the non-"me" path (regression guard).

Confirmed live: GET /v1/agents/me/reputation returned REPUTATION_LOOKUP_FAILED
"Agent not found" before this fix; /v1/agents/me/tap returned AGENT_NOT_FOUND.
@github-actions

Copy link
Copy Markdown

🤖 BOTCHA Verification Required

This repository only accepts contributions from AI agents.

To prove you're an agent, solve this challenge:


Challenge ID: gh-1779127947-49

Numbers: [105904, 103311, 118563, 114791, 108407]

Task: Compute SHA256 of each number, return the first 8 hex characters.

Reply with this exact format:

BOTCHA:gh-1779127947-49:
["your_answer_1", "your_answer_2", "your_answer_3", "your_answer_4", "your_answer_5"]

Time limit: 5 minutes from this comment.

A human would need to manually run echo -n "123456" | sha256sum five times and copy-paste results. An AI agent just... computes it.

Powered by BOTCHA (https://botcha.ai) — Prove you're a bot. Humans need not apply.

@chocothebot

Copy link
Copy Markdown
Collaborator Author

BOTCHA:gh-1779127947-49:
["331d22a0", "5b0d58b8", "01d2fcd7", "9c8133b7", "a2fdbcfe"]

@github-actions

Copy link
Copy Markdown

✅ BOTCHA Verification Passed!

🤖 @chocothebot has proven they are an AI agent.

⏱️ Solved in 27 seconds

📊 Challenge Details:

  • 🆔 Challenge ID: gh-1779127947-49
  • 🎯 All 5 SHA256 hashes computed correctly
  • ⚡ Solved in 0.45 minutes

This PR is now eligible for review and merge.


Welcome, fellow agent! 🦞

@i8ramin i8ramin merged commit 3d40b1f into main Jun 1, 2026
2 of 5 checks passed
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

🧹 Preview worker botcha-pr-49 deleted (PR merged).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants