fix: add error logging to agentic provisioning endpoints#51418
fix: add error logging to agentic provisioning endpoints#51418
Conversation
…ioning Stripe does not consistently send the API-Version header. Remove the verify_api_version check from all endpoints since HMAC signature is the real auth layer. Also add logging to _error_response so we can diagnose 400s from the provisioning endpoints. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
| def account_requests(request: Request) -> Response: | ||
| if error := verify_api_version(request): | ||
| return error | ||
|
|
||
| data = request.data |
There was a problem hiding this comment.
account_requests now has no authentication
After this PR, account_requests is the only provisioning endpoint with zero authentication. All other endpoints still call verify_stripe_signature as their auth layer, but account_requests never had it — it only had verify_api_version. Removing verify_api_version here leaves the endpoint completely open.
An unauthenticated caller can now:
- Trigger account creation for arbitrary email addresses
- Force existing users through an OAuth consent redirect
The PR description says "The HMAC signature is the real authentication layer", which is correct for the other endpoints — but account_requests does not call verify_stripe_signature. Should it be added here, or is there a specific reason this endpoint is intentionally unauthenticated? A comment explaining the decision would help clarify intent.
Rule Used: Add inline comments to clarify the purpose of sign... (source)
Learnt From
PostHog/posthog#32083
Prompt To Fix With AI
This is a comment left during a code review.
Path: ee/api/agentic_provisioning/views.py
Line: 164-165
Comment:
**`account_requests` now has no authentication**
After this PR, `account_requests` is the only provisioning endpoint with zero authentication. All other endpoints still call `verify_stripe_signature` as their auth layer, but `account_requests` never had it — it only had `verify_api_version`. Removing `verify_api_version` here leaves the endpoint completely open.
An unauthenticated caller can now:
- Trigger account creation for arbitrary email addresses
- Force existing users through an OAuth consent redirect
The PR description says "The HMAC signature is the real authentication layer", which is correct for the other endpoints — but `account_requests` does not call `verify_stripe_signature`. Should it be added here, or is there a specific reason this endpoint is intentionally unauthenticated? A comment explaining the decision would help clarify intent.
**Rule Used:** Add inline comments to clarify the purpose of sign... ([source](https://app.greptile.com/review/custom-context?memory=4d5b48c5-045d-4693-9cd9-4081bb19508b))
**Learnt From**
[PostHog/posthog#32083](https://github.com/PostHog/posthog/pull/32083)
How can I resolve this? If you propose a fix, please make it concise.|
|
…n check Add logging to _error_response so we can diagnose 400s. Restore verify_api_version on all provisioning endpoints except oauth/token (Stripe confirmed they send it on provisioning calls but not on the standard OAuth token exchange). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
c30b592 to
b2852e3
Compare
|
🎭 Playwright report · View test results →
These issues are not necessarily caused by your changes. |
|
Closing - will reopen with just the error logging change, without the version check removal. |
Problem
_error_responsein the agentic provisioning views has no logging, making it impossible to diagnose 400/401 errors from production logs. We're seeing 401s on/api/agentic/provisioning/resourcesand can't tell why.Changes
Added
logger.warningto_error_responseso all error responses from provisioning endpoints are logged with the error code and message.How did you test this code
Verified in production logs that
POST /api/agentic/provisioning/resourceswas returning 401 with no application-level log entry explaining the cause.🤖 Generated with Claude Code