Resolve ai-service directly from the RAG routes, never the gateway

This commit is contained in:
2026-08-19 10:16:44 +07:00
parent f50ccfc5f7
commit 24c55d1627
13 changed files with 470 additions and 22 deletions
+20
View File
@@ -97,6 +97,26 @@ jobs:
- name: Install
run: pnpm install --frozen-lockfile
# api-gateway proxies /auth/* and nothing else (a single
# AuthProxyController). Preferring API_GATEWAY_URL in a RAG route
# therefore breaks chat, suggest, history, sections, section-text and
# feedback the moment apiGateway is enabled -- which is exactly what
# shipped in PR #27 and stayed invisible until the config was first
# rendered on 2026-08-19. Nothing else in CI would have caught it: the
# code compiles and lints fine, and it only misbehaves once a specific
# Helm value is set. Assert the boundary directly.
- name: Assert RAG routes never resolve through api-gateway
run: |
offenders=$(grep -rln 'API_GATEWAY_URL' apps/web/app/api/chat apps/web/app/api/suggest apps/web/app/api/history apps/web/app/api/sections apps/web/app/api/section-text apps/web/app/api/feedback || true)
if [ -n "$offenders" ]; then
echo "::error::RAG routes must use AI_SERVICE_URL, not API_GATEWAY_URL: $offenders"
exit 1
fi
# ...and auth must keep using it, or login silently talks to the
# wrong service instead.
grep -q 'API_GATEWAY_URL' apps/web/app/api/auth/login/route.ts
grep -q 'API_GATEWAY_URL' apps/web/app/api/auth/me/route.ts
- name: Lint
run: pnpm --filter @duoc-thu/web lint
+22
View File
@@ -0,0 +1,22 @@
name: Disable apiGateway on production (restore chat)
# Emergency: enabling apiGateway sets API_GATEWAY_URL on the web pod, which
# every BFF route prefers over AI_SERVICE_URL -- but the gateway only proxies
# /auth/*, so chat/suggest/history/sections/section-text/feedback all break.
# See the script docstring for the full trace.
on:
workflow_dispatch: {}
jobs:
disable:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Disable apiGateway and sync
env:
ARGOCD_PRACTICE_URL: ${{ secrets.ARGOCD_PRACTICE_URL }}
ARGOCD_PRACTICE_PASSWORD: ${{ secrets.ARGOCD_PRACTICE_PASSWORD }}
run: python3 .github/scripts/disable_api_gateway_live.py
@@ -0,0 +1,23 @@
name: Repair ArgoCD inline values
# One-off repair for the folded-block-scalar corruption a manual UI edit left
# on medical-chatbot-app's inline helm values on 2026-08-18 -- see the module
# docstring in .github/scripts/repair_argocd_inline_values.py for the full
# diagnosis. The script refuses to write unless it finds that exact
# corruption, so running it once the Application is healthy is a no-op.
on:
workflow_dispatch: {}
jobs:
repair:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Repair and sync
env:
ARGOCD_PRACTICE_URL: ${{ secrets.ARGOCD_PRACTICE_URL }}
ARGOCD_PRACTICE_PASSWORD: ${{ secrets.ARGOCD_PRACTICE_PASSWORD }}
run: python3 .github/scripts/repair_argocd_inline_values.py