Skip to content

COPLAN-SQUARE-14: Direct agents to the API - #207

Merged
HamptonMakes merged 1 commit into
mainfrom
hampton/COPLAN-SQUARE-14/agent-api-instructions
Sep 3, 2026
Merged

COPLAN-SQUARE-14: Direct agents to the API#207
HamptonMakes merged 1 commit into
mainfrom
hampton/COPLAN-SQUARE-14/agent-api-instructions

Conversation

@HamptonMakes

Copy link
Copy Markdown
Collaborator

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

  • Return the existing Markdown API-instructions response for non-browser GETs before web authentication
  • Preserve authenticated non-GET requests such as Web Push registration
  • Cover the production failure mode with an authenticated curl regression test

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

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>
@HamptonMakes
HamptonMakes marked this pull request as ready for review September 2, 2026 14:30
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-02T14:33:51.745540Z 11f97ee Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@HamptonMakes
HamptonMakes merged commit be9e7f7 into main Sep 3, 2026
6 checks passed
@HamptonMakes
HamptonMakes deleted the hampton/COPLAN-SQUARE-14/agent-api-instructions branch September 3, 2026 21:23
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