Repository navigation
feat: support short task links like /PRJ-1 - #778
Conversation
Add GET /tasks/by-key/{taskKey} (authorized on the resolved task), a
/$taskKey web route that redirects to the task page, and use the short
link for the share/copy-link actions.
There was a problem hiding this comment.
Caution
The API's integration-test package no longer compiles, and the tracked TanStack route tree was not regenerated, so the web app fails tsc -b on a clean checkout. One design gap also needs a decision: a short link can open a different project's task.
Reviewed changes
- Short-link API —
GET /api/v1/tasks/by-key/{taskKey}parsesPREFIX-N, resolves it with a newFindTaskByKeyquery (oldest project wins on a shared prefix), and gates ontasks:readagainst the resolved task. - Short-link route —
/$taskKeyrejects paths that aren't key-shaped, resolves the key, and replaces the URL with the canonical task page. - Share links — the task header and context menu now copy
/PREFIX-NviataskShareUrl, falling back to the canonical URL when the project has no prefix. - Tests — key parser, handler, gate resolver, and route-coverage additions.
🚨 services/api/test/integration no longer compiles
TaskRepository gained FindTaskByKey, but the package's fakeTaskRepo was not updated, so every tasksvc.New / sprintsvc.New / NewViewService / NewTaskOwnerChecker call in the package fails to typecheck. The API PR workflow runs this package, so the suite is red before any test executes.
Technical details
# Integration test fake is missing `FindTaskByKey`
## Affected sites
- `services/api/test/integration/task_test.go:418` — `fakeTaskRepo` implements `FindTaskByID`/`FindTaskByNumber` but not `FindTaskByKey`, so it no longer satisfies `taskdom.Repository` and `taskdom.TaskRepository`.
- `services/api/test/integration/agent_apikey_test.go:65-67`, `attachment_test.go:281-285` (and `313`, `340`), plus the other `tasksvc.New` / `sprintsvc.New` / `NewViewService` / `NewTaskOwnerChecker` call sites in the package.
## Required outcome
- `go test ./test/integration/` compiles again; the fake answers `FindTaskByKey` consistently with its `FindTaskByNumber` (returning `taskdom.ErrTaskNotFound` is fine).
## Evidence
- `cd services/api && go test -run TestNothingMatches ./test/integration/` → `cannot use taskRepo (variable of type *fakeTaskRepo) as taskdom.Repository value ... (missing method FindTaskByKey)`.
- `.github/workflows/api-pr-ci.yml:110` runs `go test ... $(go list ./... | grep -v '/test/e2e')`, which includes this package.⚠️ A shared link can open a different project's task
task_id_prefix has no uniqueness constraint and suggestPrefix derives it from the project name, so two projects routinely end up with the same prefix. The new query then picks the oldest project, which means Share/Copy link on the newer project's task #N emits a URL that opens the older project's task #N — silently, for anyone with access to both. The PR body notes the ambiguity, but the consequence for the feature being added (and for anyone who receives the link) is worth an explicit decision rather than a caveat.
Technical details
# Short URLs are not unique across projects
## Affected sites
- `services/api/migrations/000001_init.sql:57` — `task_id_prefix TEXT NOT NULL DEFAULT ''`, no unique index.
- `services/api/internal/service/project/project_service.go:44` (`suggestPrefix`) and `:298` (`validatePrefix`) — the prefix is derived from the name and validated only for shape.
- `services/api/internal/repository/postgres/task_repository.go:1602-1612` — `ORDER BY p.created_at ASC LIMIT 1` decides the collision.
- `apps/web/src/lib/interaction-api.ts:865-867` — `taskShareUrl` emits the short form unconditionally when a prefix exists.
## Required outcome
- Choose one: enforce a case-insensitive unique prefix on project create/update (with a migration or suffixing for existing duplicates), or fall back to the canonical `/projects/.../tasks/...` URL whenever a prefix is shared.
- Whichever way it goes, pin the tie-break with a repository test; the PG tests are `PACA_TEST_PG_DSN`-gated and nothing currently covers `FindTaskByKey` itself.
## Open questions for the human
- Is the short link intended to be the primary share link, or a convenience that may fall back to the canonical URL when ambiguous?deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
| } | ||
| t, err := lookup.FindTaskByKey(r.Context(), prefix, number) | ||
| if errors.Is(err, taskdom.ErrTaskNotFound) { | ||
| return "task-key/" + raw, nil |
There was a problem hiding this comment.
A not-found (and a malformed) key resolves to task-key/<raw>, which no policy names, so ordinary callers get 403 before the handler runs — GetTaskByKey's 400/404 branches and the new NotFoundReturns404 / InvalidKeyReturns400 handler tests never exercise the production path. Avoiding an existence oracle is a good reason to keep it, but the endpoint's real contract is then "403 for anything you cannot resolve", so say that here explicitly.
Technical details
# Unknown keys are denied at the gate, not answered by the handler
## Affected sites
- `services/api/internal/transport/http/middleware/resource_lookup.go:187,194` — malformed and not-found keys both return `task-key/<raw>`.
- `services/api/internal/transport/http/handler/task_handler.go:1122` — the 400/404 branches are only reachable for a wildcard-grant holder, or in a router built without the gate (as in `task_handler_test.go:536`).
## Required outcome
- Document the 403 contract on the resolver (or handler), and add a router-level test with a real authorizer asserting a project member gets 403 for a mistyped key, so the intended behaviour is pinned.There was a problem hiding this comment.
✅ No new issues found in the new commits.
Reviewed changes
The two commits since the prior review fix the integration-test compile failure, regenerate the tracked route tree, and document the short-link endpoint's authorization contract.
- Route tree regenerated —
apps/web/src/routeTree.gen.tsnow registers/$taskKeyin every generated section;bun run build(tsc + vite) passes and the generator leaves the committed file unchanged. - Integration fake completed —
fakeTaskRepo.FindTaskByKeyreturnstaskdom.ErrTaskNotFound, matching itsFindTaskByNumber;services/api/test/integrationcompiles again andgo vetis clean across the API packages. - 403 contract documented —
TaskByKeyResourcenow explains that unresolvable keys are refused at the gate and why the handler's400/404answers are wildcard-only.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
pikann
left a comment
There was a problem hiding this comment.
LGTM! Thank you for the contribution! 🚀

Summary
Adds support for short task links such as
paca.example.com/PRJ-1.GET /api/v1/tasks/by-key/{taskKey}. It looks a task up by project prefix and number, case-insensitively, and checkstasks:readon the task it resolves to./$taskKeyroute that resolves the key and redirects to/projects/:projectId/tasks/:taskId. Anything that isn't shaped like a key shows a 404.Type of Change
Checklist