fix(logs): dual-register logs_config under /api/projects/ and /api/environments/#60967
Merged
Merged
Conversation
Contributor
|
Reviews (1): Last reviewed commit: "fix(logs): point logs_config fetch back ..." | Re-trigger Greptile |
Contributor
|
Size Change: 0 B Total Size: 80.9 MB ℹ️ View Unchanged
|
Contributor
|
✅ Visual changes approved by @DanielVisca — baseline updated in 11 changed, 4 new. |
6d9a947 to
f78dd88
Compare
Contributor
MCP UI Apps size report
|
Contributor
There was a problem hiding this comment.
Additive URL alias pattern following established conventions — extracts existing inline handler to module-level and registers it under both /api/projects/ and /api/environments/. No logic changes, no security issues, and tests thoroughly verify both routes share the same config.
…vironments/ PR #60407 rewrote the frontend URL from `api/environments/.../logs_config/` to `api/projects/.../logs_config/` to align with the canonical-project-route direction, but the backend action lives on `TeamViewSet` as an `@action` which is only mounted under `environments_router`. The projects router uses `ProjectViewSet` (a different class), so the rewritten URL hit the catch-all 404 in production. Fix it properly by mirroring the action on `ProjectViewSet` so both routes resolve. The shared body is extracted to `handle_logs_config()` so the two viewsets stay in sync. Both routes operate on the same env-scoped `TeamLogsConfig` keyed by `team_id` — the project-side action looks up `project.passthrough_team`, matching the pattern used by `reset_token` and the other existing project-side actions. Frontend is restored to `api/projects/...` per #60407's canonical direction. Tests are parameterized across both URL prefixes plus a cross-route consistency assertion that confirms writes via one prefix are readable via the other. Generated-By: PostHog Code Task-Id: a0cd1bfc-9b19-4b30-9123-6488d22b3f6a
b057746 to
ed34d8e
Compare
MattPua
pushed a commit
that referenced
this pull request
Jun 1, 2026
This was referenced Jun 1, 2026
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.
Problem
Production
Load logs config failed: Endpoint not found.on the person profile Logs tab. The frontend calls/api/projects/:team_id/logs_config/which 404s because the backend@actiononly exists under/api/environments/.Root cause
PR #60407 (the sweep that makes
/api/projects/canonical for env-only endpoints) mechanically rewrote URL strings inlogsConfigLogic.tsfromapi/environments/toapi/projects/. Butlogs_configis an@action(detail=True)onTeamViewSet, not arouter.register(...)call — the sweep's script only converted env-routerregister(...)calls, so the backend was never dual-registered. The projects router usesRootProjectViewSet(ProjectViewSet), a different class that doesn't carry the@action.The sibling
experiments_configaction has the same gap; it still works only because its frontend file wasn't swept by #60407.Fix
Align with #60407's canonical-
/api/projects/direction by mirroringlogs_configonProjectViewSet:handle_logs_config(request, team)inposthog/api/team.pyso both viewsets share one implementation.@actiontoProjectViewSetthat looks upproject.passthrough_team(the same patternreset_token,rotate_secret_token, and other project-side actions use to operate on team-scoped state).api/projects/...per the canonical direction.Both routes operate on the same env-scoped
TeamLogsConfigkeyed byteam_id.Tests
Existing
test_team_logs_config.pytests are parameterized across both URL prefixes (/api/projects/and/api/environments/), plus a new cross-route consistency test confirms a write through one prefix is visible via the other. 13/13 passing locally.Agent context
Authored by PostHog Code (Opus 4.7).
Discovery flow:
/api/projects/2/logs_config/returning 404, while/api/environments/2/logs_config/returned 200.logs_configlives onTeamViewSetas an@action, registered only viaenvironments_router→RootTeamViewSet(TeamViewSet). The projects router usesRootProjectViewSet(ProjectViewSet), which doesn't inherit the action.git blametraced the frontend URL change to commit7ce43b8f9d(PR chore(devex): register canonical /api/projects/ route for env-only endpoints #60407 — "register canonical /api/projects/ route for env-only endpoints"). Its mechanical script only convertedenvironments_router.register(...)calls; it did not inspect@actiondecorators onTeamViewSet/ProjectViewSet.experimentsConfigLogic.ts(sibling endpoint, same shape) was NOT swept by that PR. Confirms our backend implementation followed the existing convention.Decisions:
experiments_configprecedent but moves us back toward/api/environments/for a team-scoped endpoint — against chore(devex): register canonical /api/projects/ route for env-only endpoints #60407's stated direction. Adding the project-side action fixes prod and aligns with the canonical-/api/projects/direction the codebase is moving toward.project.passthrough_teamrather than introducing a new resolution path. Matches existing project-side actions (reset_token,rotate_secret_token,delete_secret_token_backup,generate_conversations_public_token).Out of scope (potential follow-ups):
experiments_confighas the same gap; it just hasn't been swept yet on the frontend. Same fix pattern would apply if/when needed.@extend_schemato surface these endpoints in the generated OpenAPI client would let frontend code drop the hand-rolledapi.get()and remove the// nosemgrep: prefer-codegen-apimarker.Created with PostHog Code