Skip to content

fix(customer-analytics): allow api keys on feature request actions - #89646

Merged
trunk-io[bot] merged 4 commits into
masterfrom
fix/feature-request-action-scopes
Aug 26, 2026
Merged

fix(customer-analytics): allow api keys on feature request actions#89646
trunk-io[bot] merged 4 commits into
masterfrom
fix/feature-request-action-scopes

Conversation

@arthurdedeus

Copy link
Copy Markdown
Contributor

Problem

API keys and OAuth tokens cannot use most of the feature request API. Every custom action returns 403 with "This action does not support personal API key access", so the MCP tools for adding evidence, archiving, and reading history are broken for everyone.

The custom actions on FeatureRequestViewSet declare no required_scopes, and the scope framework fails closed for undeclared actions. The standard CRUD methods work because they map to default scopes.

Changes

  • A personal API key or OAuth token with customer_analytics:write can now call add_account, add_evidence, update_evidence, remove_evidence, archive, and restore.
  • One with customer_analytics:read can now call history and status_history.
  • The diff only adds required_scopes to the eight @action decorators. Session auth is unaffected.

How did you test this code?

  • Added test_scoped_personal_api_key_can_use_custom_actions: a write-scoped personal API key calls add_evidence and history. It fails with 403 without the fix and passes with it. No existing test authenticated these endpoints with an API key.
  • Ran the feature request suite locally plus hogli ci:preflight --fix.

Automatic notifications

  • Publish to changelog?

Docs update

None. No documented workflow changes.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Claude Code session. The 403 surfaced while filing feature requests through the MCP feature-requests-add-evidence-create tool; the session confirmed the missing required_scopes in the viewset and fixed all sibling actions. Skills invoked: /improving-drf-endpoints, /writing-tests, /writing-pr-descriptions.

@arthurdedeus arthurdedeus self-assigned this Aug 26, 2026
@trunk-io

trunk-io Bot commented Aug 26, 2026

Copy link
Copy Markdown

😎 Merged successfully - details.

@arthurdedeus
arthurdedeus marked this pull request as ready for review August 26, 2026 18:42
@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team August 26, 2026 18:43
@github-actions

Copy link
Copy Markdown
Contributor

🤖 CI report

⚠️ Trunk lane — backend Python lane

This PR is assigned to the backend Python lane. It runs backend Python tests and may merge in parallel with PRs in other lanes.

@greptile-apps

greptile-apps Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(customer-analytics): allow api keys ..." | Re-trigger Greptile

@arthurdedeus arthurdedeus added the stamphog Request AI approval (no full review) label Aug 26, 2026
@trunk-io

trunk-io Bot commented Aug 26, 2026

Copy link
Copy Markdown

Static BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@arthurdedeus arthurdedeus added stamphog Request AI approval (no full review) and removed stamphog Request AI approval (no full review) labels Aug 26, 2026

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds required_scopes to eight actions that previously had none (fail-closed for API keys), narrowly scoped to the correct existing customer_analytics:read/write scopes and backed by a new test proving the fix; author is on the owning team with 100% familiarity of the touched lines, satisfying independent assurance for this auth-adjacent change.

  • Author wrote 100% of the modified lines and has 69 merged PRs in these paths (familiarity STRONG).
  • 👍 on the PR from greptile-apps[bot].
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 16L, 1F substantive, 51L/2F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1b-small (51L, 2F, single-area, fix)
stamphog 2.0.0b4 .stamphog/policy.yml @ 479667e · reviewed head 479667e

@trunk-io
trunk-io Bot merged commit 56b53ff into master Aug 26, 2026
354 of 367 checks passed
@trunk-io
trunk-io Bot deleted the fix/feature-request-action-scopes branch August 26, 2026 22:00
@deployment-status-posthog

deployment-status-posthog Bot commented Aug 26, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-08-26 22:30 UTC Run
prod-us ✅ Deployed 2026-08-26 22:52 UTC Run
prod-eu ✅ Deployed 2026-08-26 22:57 UTC Run

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

Labels

stamphog Request AI approval (no full review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant