COPLAN-SQUARE-14: Direct agents to the API - #207
Conversation
Authenticated non-browser GETs previously slipped through to web view rendering and could negotiate a nonexistent Markdown template. Return the existing API instructions response before web authentication instead. Amp-Thread-ID: https://ampcode.com/threads/T-01a043c0-9e59-7177-b513-9bc229ba3b59 Co-authored-by: Amp <amp@ampcode.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 11f97ee091
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| end | ||
|
|
||
| def authenticate_coplan_user! | ||
| if request.get? && agent_request? |
There was a problem hiding this comment.
Preserve API guidance for unauthenticated non-GET agents
When an unauthenticated curl or agent sends POST/PATCH/DELETE to a web route, this GET-only branch is skipped. Previously, the unless @current_coplan_user agent branch returned the Markdown API instructions for every method; after this change, a host with sign_in_path instead returns a 302 to the human sign-in page (or a bare 401 without one), so these clients lose the guidance to use the REST API. Keep the unauthenticated-agent fallback while exempting only authenticated non-GET requests.
AGENTS.md reference: AGENTS.md:L3-L5
Useful? React with 👍 / 👎.
Why
Authenticated non-browser GETs could bypass the CoPlan agent redirect and fall through to web rendering. A curl request negotiating Markdown then caused an ActionView::MissingTemplate error instead of directing the caller to the API.
What
Risk Assessment
Low. The change is limited to GET requests whose user agent is not browser-like; browser traffic and API controllers are unchanged.
References
Generated with Amp