Repository navigation
[codex] Add hermetic OpenAPI contract drift check - #8629
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2425f1892e
ℹ️ 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".
| class DeveloperMemory(BaseModel): | ||
| model_config = ConfigDict(title='DeveloperMemory') |
There was a problem hiding this comment.
Restore memory metadata in developer responses
When clients call the Developer memory endpoints for records that contain scoring, reviewed, user_review, or edited, this replacement response model now filters those fields out of the live FastAPI response; previously CleanerMemory exposed the review fields on list/update and MemoryResponse exposed scoring on create/batch. This changes production API payloads, not just the generated OpenAPI contract, so integrations that rely on memory review state or scoring lose data.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
4 issues found across 6 files
Confidence score: 2/5
backend/routers/developer.pyswitches developer memory responses to a model that dropsscoring,reviewed,user_review, andedited, which is a concrete API contract break for clients consuming list/create/update/batch payloads; merging as-is is likely to cause downstream parsing/UI regressions — restore those fields (or version the endpoint and update consumers) before merging.backend/routers/developer.pyhasDeveloperFolderdefaults that can diverge fromFolder, so legacy docs without color/icon may trigger 500s inlistFolders; this creates a user-facing reliability risk on existing data — align defaults withFolderand add a regression test for legacy folder documents before merging.backend/tests/unit/test_openapi_contract.pyuses an overly broad route match for the "exact" audit, so the test can pass while validating the wrong endpoint and miss real contract drift; this weakens protection around API changes — tighten the pattern with an end anchor (or equivalent precise match) before merge.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/test-preflight.sh">
<violation number="1" location="backend/test-preflight.sh:143">
P3: Redundant stderr redirect after `&>/dev/null`. Use `&>/dev/null` alone or `>/dev/null 2>&1`, not both.</violation>
</file>
<file name="backend/routers/developer.py">
<violation number="1" location="backend/routers/developer.py:925">
P2: Keep DeveloperFolder defaults aligned with Folder; otherwise legacy folder docs missing color/icon can turn listFolders into a 500.</violation>
</file>
<file name="backend/tests/unit/test_openapi_contract.py">
<violation number="1" location="backend/tests/unit/test_openapi_contract.py:88">
P3: Test name says "exact" route is audited but match pattern is too broad — it matches both `/v1/conversations` and `/v1/conversations/from-segments`. Use `$` anchor or a more precise match to isolate the target route.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| color: str | ||
| icon: str |
There was a problem hiding this comment.
P2: Keep DeveloperFolder defaults aligned with Folder; otherwise legacy folder docs missing color/icon can turn listFolders into a 500.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/routers/developer.py, line 925:
<comment>Keep DeveloperFolder defaults aligned with Folder; otherwise legacy folder docs missing color/icon can turn listFolders into a 500.</comment>
<file context>
@@ -873,7 +916,23 @@ def normalize_client_session_id(cls, value: Optional[str]) -> Optional[str]:
+ id: str
+ name: str
+ description: Optional[str] = None
+ color: str
+ icon: str
+ created_at: datetime
</file context>
| color: str | |
| icon: str | |
| color: str = '#6B7280' | |
| icon: str = 'folder' |
| bad "backend unit test selection failed" | ||
| fi | ||
|
|
||
| if [[ -n "$PYTHON_BIN" ]] && "$PYTHON_BIN" scripts/export_openapi.py --help &>/dev/null 2>&1; then |
There was a problem hiding this comment.
P3: Redundant stderr redirect after &>/dev/null. Use &>/dev/null alone or >/dev/null 2>&1, not both.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/test-preflight.sh, line 143:
<comment>Redundant stderr redirect after `&>/dev/null`. Use `&>/dev/null` alone or `>/dev/null 2>&1`, not both.</comment>
<file context>
@@ -140,6 +140,12 @@ else
bad "backend unit test selection failed"
fi
+if [[ -n "$PYTHON_BIN" ]] && "$PYTHON_BIN" scripts/export_openapi.py --help &>/dev/null 2>&1; then
+ ok "OpenAPI export script is runnable"
+else
</file context>
| if [[ -n "$PYTHON_BIN" ]] && "$PYTHON_BIN" scripts/export_openapi.py --help &>/dev/null 2>&1; then | |
| if [[ -n "$PYTHON_BIN" ]] && "$PYTHON_BIN" scripts/export_openapi.py --help &>/dev/null; then |
| def create_first_party_conversation(): | ||
| return {'ok': True} | ||
|
|
||
| with pytest.raises(export_openapi.OpenAPIContractError, match='POST /v1/conversations'): |
There was a problem hiding this comment.
P3: Test name says "exact" route is audited but match pattern is too broad — it matches both /v1/conversations and /v1/conversations/from-segments. Use $ anchor or a more precise match to isolate the target route.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/tests/unit/test_openapi_contract.py, line 88:
<comment>Test name says "exact" route is audited but match pattern is too broad — it matches both `/v1/conversations` and `/v1/conversations/from-segments`. Use `$` anchor or a more precise match to isolate the target route.</comment>
<file context>
@@ -0,0 +1,235 @@
+ def create_first_party_conversation():
+ return {'ok': True}
+
+ with pytest.raises(export_openapi.OpenAPIContractError, match='POST /v1/conversations'):
+ export_openapi.build_public_openapi(app)
+
</file context>
| with pytest.raises(export_openapi.OpenAPIContractError, match='POST /v1/conversations'): | |
| with pytest.raises(export_openapi.OpenAPIContractError, match=r'POST /v1/conversations\b(?!/)'): |
Summary
docs/api-reference/openapi.jsonfrom the audited route surface and adds CI coverage.Validation
.venv/bin/python scripts/export_openapi.py --check ../docs/api-reference/openapi.json-> passed.venv/bin/pytest tests/unit/test_openapi_contract.py -q-> 14 passedbash backend/test-preflight.shpassed during prep with optional local warningsFixes #8546