Skip to content

fix: adjust project routes to use consistent path structure#285

Merged
pikann merged 2 commits into
masterfrom
fix/adjust-project-routes
Jul 17, 2026
Merged

fix: adjust project routes to use consistent path structure#285
pikann merged 2 commits into
masterfrom
fix/adjust-project-routes

Conversation

@pikann

@pikann pikann commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@pullfrog pullfrog Bot 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.

Important

This change correctly fixes the chi shadowing issue, but the regressed route has no test coverage. Please add a regression test for /projects/workspace-stats before merging.

Reviewed changes — Switches project collection routes from r.Route("/projects") to r.Group(), registering full /projects paths so the static collection routes are not shadowed by the later /projects/{projectId} mount.

  • services/api/internal/transport/http/router/router.go — registers list, workspace-stats, and create with full /projects paths under a Group to coexist with the parameterized project router.

⚠️ Missing regression coverage for /projects/workspace-stats

No existing test or integration case hits GET /api/v1/projects/workspace-stats. Since this PR exists specifically because chi was shadowing that route with /projects/{projectId}, a regression test is the best way to keep the bug from reappearing if the route tree is reorganized again.

Technical details
# Missing regression coverage for /projects/workspace-stats

## Affected sites
- `services/api/test/integration/project_test.go` — project integration tests cover list/create/get but not workspace-stats.
- `services/api/internal/transport/http/router/router_test.go` — router tests currently do not include a `Project` handler, so they also miss this path.

## Required outcome
- An authenticated request to `GET /api/v1/projects/workspace-stats` reaches `Project.GetWorkspaceStats` and returns a non-404/non-parameter-error response.
- The test should fail if the static route is again shadowed by `/projects/{projectId}`.

## Suggested approach
- Add a case in `services/api/test/integration/project_test.go` (or another appropriate router/integration test) that creates a project, then hits `/api/v1/projects/workspace-stats` and verifies `200 OK` and the expected stats payload shape.
- If `router_test.go` is the preferred place, wire a minimal `Project` stub in `Deps` and assert routing/middleware behavior; otherwise an integration-level test already has the real handler available.

Pullfrog  | Fix it ➔View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot 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.

✅ No new issues found.

Reviewed changes — The new commit wires a project service stub into the router tests and adds regression coverage for the chi route-shadowing fix.

  • Added stubProjectSvc and wired Project handler in router_test.go — implements the project-domain service interface and registers handler.NewProjectHandler in newTestRouterWithStore so the project collection routes can be exercised in isolation.
  • Replaced the inline authz.NewAuthorizer(store) call with a shared authorizer variable — the handler and middleware Authorizer now point to the same instance inside newTestRouterWithStore.
  • Added TestProjectsRoute_WorkspaceStats_NotShadowedByProjectIDRoute — asserts that GET /api/v1/projects/workspace-stats returns 200 OK and a body containing open_task_count, covering the shadowing regression flagged in the prior review.
  • Added TestProjectsRoute_GetByID_StillParsesProjectID — asserts that GET /api/v1/projects/{uuid} still reaches the project-ID route and returns 404 for an unknown project, ensuring the new group registration did not break parameterized project routes.

Pullfrog  | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

@pikann
pikann merged commit c98e43d into master Jul 17, 2026
4 checks passed
@pikann
pikann deleted the fix/adjust-project-routes branch July 17, 2026 14:39
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