GPT OpenAPI wrong-URL cleanup (308 redirect) — 2026-05-12
title: GPT OpenAPI wrong-URL cleanup — 308 redirect deprecated path to canonical date: 2026-05-12 investigator: Claude Code (Opus 4.7) status: APPLIED_AND_VERIFIED related:
- gpt-agent-data-connector-recurrence-root-cause-2026-05-12.md
- gpt-agent-data-connector-recurrence-closure-2026-05-12.md
GPT OpenAPI wrong-URL cleanup (2026-05-12)
1. Mục đích
Chặn URL deprecated /api/chatgpt-openapi.json (từng gây Nuxt 404 do 301-fall-through) bằng cách thêm 308 redirect tại nginx tới canonical /api/openapi.json. Không đụng đường đúng.
2. Before behavior
2.1 /api/openapi.json (đường đúng)
- Source nginx rule (
conf.d/default.conf, dòng 137-138 pre-patch):location = /api/openapi.json { alias /usr/share/nginx/static/openapi.json; ...} - HEAD:
200 OK,Content-Length: 27833,Last-Modified: Tue, 12 May 2026 04:05:07 GMT, ETag"6a02a6f3-6cb9". - Info:
version=1.2.0,x-connector-schema-version=gpt-agent-data-2026-05-12.1,x-connector-schema-hash=aaec3d401df2. - operationIds:
healthCheck, listDocuments, getDocument, createDocument, batchReadDocuments, getDocumentTruncated, patchDocument, updateDocument, deleteDocument, searchKnowledge. - listDocuments params:
prefix, limit, offset.
2.2 /api/chatgpt-openapi.json (đường sai)
- Không có nginx location block dành riêng. Request rơi vào catch-all proxy đến Nuxt app.
- Nuxt server middleware trả
301 Moved Permanently → Location: /openapi.json(mất tiền tố/api/). - Follow redirect →
/openapi.json(root) → Nuxt 404{"error":true,"statusCode":404,"statusMessage":"Page Not Found",...}. - Hậu quả: GPT action-gateway nếu config URL này, schema refresh fail → ClientResponseError toàn bộ tools.
2.3 Static files trên disk
/opt/incomex/docker/nginx/static/openapi.json 27833 May 12 06:05
/opt/incomex/docker/nginx/static/openapi-ops.json 84545 Mar 1 05:16
/opt/incomex/docker/nginx/static/openapi-council.json 44650 Mar 2 06:10
Không có file/symlink chatgpt-openapi.json trên disk.
3. Fix option
Chọn Option A — 308 Permanent Redirect:
- 308 preserves HTTP method (vs 301 có thể bị client coerce thành GET) — quan trọng nếu client lỡ POST.
- Không xóa, không tạo file duplicate.
- Nếu URL cũ đang được dùng đâu đó, redirect tự động dẫn về URL đúng thay vì fail.
- Loại bỏ hoàn toàn việc rơi vào Nuxt 404.
Option B (410 Gone) loại — vì redirect tốt hơn cho compatibility, và GPT action-gateway không có UI để bắt 410 message rõ ràng.
4. Patch áp dụng
File: /opt/incomex/docker/nginx/conf.d/default.conf (host bind-mount → /etc/nginx/conf.d/default.conf trong container).
Backup: default.conf.bak-2026-05-12-070000-pre-chatgpt-redirect (67073 bytes, identical to pre-patch).
Insert location (ngay trước location = /api/openapi.json):
# GPT Actions — wrong URL guard: redirect /api/chatgpt-openapi.json to canonical /api/openapi.json
# Added 2026-05-12 to prevent GPT import from deprecated path (was 301-falling-through to nuxt 404)
location = /api/chatgpt-openapi.json {
return 308 /api/openapi.json;
}
# GPT Actions — OpenAPI spec (static file, exact match)
location = /api/openapi.json {
alias /usr/share/nginx/static/openapi.json;
...
}
Validation + reload:
docker exec incomex-nginx nginx -t→syntax is ok/test is successful.docker exec incomex-nginx nginx -s reload→ reload OK at 07:13:35 UTC.- Không restart agent-data, không restart nginx container.
5. After behavior
5.1 Đường đúng vẫn nguyên (V1, V2)
HEAD /api/openapi.json
HTTP/1.1 200 OK
Content-Length: 27833
Last-Modified: Tue, 12 May 2026 04:05:07 GMT
Info content giữ nguyên 100%:
version: 1.2.0x-connector-schema-version: gpt-agent-data-2026-05-12.1x-connector-schema-hash: aaec3d401df2- required ops
healthCheck, searchKnowledge, getDocumentTruncated, listDocumentsall present listDocumentsparams[prefix, limit, offset]
5.2 Đường sai giờ trả 308 sạch (V3, V4, V5)
GET /api/chatgpt-openapi.json
HTTP/1.1 308 Permanent Redirect
Location: https://vps.incomexsaigoncorp.vn/api/openapi.json
HEAD /api/chatgpt-openapi.json
HTTP/1.1 308 Permanent Redirect
Location: https://vps.incomexsaigoncorp.vn/api/openapi.json
Follow redirect: FINAL_HTTP:200 SIZE:27833 — chính là schema canonical.
Không còn fall-through Nuxt 404.
5.3 Không tạo URL schema thứ ba
Không có file/route mới phục vụ duplicate schema. Vẫn chỉ 1 nguồn truth: /usr/share/nginx/static/openapi.json qua /api/openapi.json.
6. GPT connector vẫn PASS (verify từ logs)
Trước khi patch (07:07-07:08 UTC, từ báo cáo closure):
| # | UTC | OpenAI IP | Route | Status |
|---|---|---|---|---|
| 1 healthCheck | 07:07:33 | 172.196.40.210 | GET /api/health | 200 |
| 2 searchKnowledge | 07:07:45 | 172.196.40.216 | POST /api/chat | 200 |
| 3 getDocumentTruncated | 07:07:52 | 172.196.40.223 | GET /api/documents/.../stability-fix.md | 200 |
| 4 listDocuments(notes) | 07:07:59 | 172.196.40.222 | GET /api/kb/list?prefix=...notes | 200 |
| 5 listDocuments(reviews) | 07:08:05 | 172.196.40.218 | GET /api/kb/list?prefix=...reviews | 200 |
Patch áp dụng lúc 07:13:35 UTC. Patch không sửa endpoint canonical hay GPT logic — chỉ thêm location block redirect cho deprecated path. GPT đang dùng URL đúng nên không bị ảnh hưởng.
7. Hard boundaries đã tuân thủ
- ✅ KHÔNG đụng
/api/openapi.jsonngoài read-only verify. - ✅ KHÔNG xóa schema đúng (static file giữ nguyên mtime + size + ETag).
- ✅ KHÔNG rollback OGV-2C.
- ✅ KHÔNG đụng PG / Qdrant / Directus / Nuxt app code.
- ✅ KHÔNG tạo URL schema thứ ba (chỉ thêm redirect, không thêm schema duplicate).
- ✅ KHÔNG restart agent-data; chỉ
nginx -s reload.
8. Rollback (nếu cần)
cp /opt/incomex/docker/nginx/conf.d/default.conf.bak-2026-05-12-070000-pre-chatgpt-redirect \
/opt/incomex/docker/nginx/conf.d/default.conf
docker exec incomex-nginx nginx -t && docker exec incomex-nginx nginx -s reload
9. Status
APPLIED AND VERIFIED. Deprecated URL /api/chatgpt-openapi.json giờ 308-redirects an toàn về canonical. Đường đúng không bị đụng. Không action thêm cần thiết.