Skip to content

fix(frontend): plumb VITE_BUG_REPORTING_ENABLED / VITE_BUG_INTAKE_URL as prod build args (#1489) - #1492

Merged
vybe merged 5 commits into
devfrom
AndriiPasternak31/issue-1489
Jul 7, 2026
Merged

vybe merged 5 commits into
devfrom
AndriiPasternak31/issue-1489

Conversation

@AndriiPasternak31

@AndriiPasternak31 AndriiPasternak31 commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Plumbs the two advertised in-app bug-reporting build knobs — VITE_BUG_REPORTING_ENABLED and VITE_BUG_INTAKE_URL — through the production frontend build path so they actually reach the shipped image. Before this, HelpChatWidget.vue (#1116) read both via import.meta.env, but docker/frontend/Dockerfile.prod declared only VITE_API_URL and docker-compose.prod.yml forwarded only that — so VITE_BUG_REPORTING_ENABLED=false in .env was inert and every standard prod build shipped with reporting on, pointed at the hosted intake, with no supported off switch.

Same packaging-gap class as #1039 / #1056, on the frontend build-arg surface instead of the compose environment: surface (Vite statically inlines import.meta.env.* at npm run build, so the lever must arrive as an ARG/ENV build arg, not runtime env).

Fixes #1489 · finding #4 of umbrella #1485.

Changes

  • docker/frontend/Dockerfile.prod — ARG VITE_BUG_REPORTING_ENABLED + ARG VITE_BUG_INTAKE_URL (with code-default values), exported as ENV before RUN npm run build.
  • docker-compose.prod.yml — frontend build.args forwards both with ${VAR:-default} fallbacks.
  • .env.example — both documented, with a "VITE_* is world-readable, never a secret" warning and the CSP caveat.
  • tests/unit/test_1489_vite_bug_build_args.py — 7 static guards over every layer, plus the load-bearing invariant that Dockerfile ARG default == compose ${VAR:-…} == HelpChatWidget.vue code default, so an unset .env byte-reproduces today's behavior.
  • Feature-flow in-app-bug-reporting.md + index row updated.

Scope / boundaries

  • The disable switch works end-to-end. Repoint (VITE_BUG_INTAKE_URL → self-hosted host) is still CSP-blocked because the intake host is hard-coded in security-headers.conf + vite.config.js; parameterizing the CSP from the build arg is a deferred Config Validation: 4 critical config issues found (2026-07-06) #1485 follow-up. The AC asks for the disable lever, which is delivered.
  • Dev compose is unaffected (the Vite dev server reads .env natively).

Relation to umbrella #1485

This closes finding #4 only. The other three findings (OPERATOR_INTAKE_ENABLED/DO_NOT_TRACK, DISPATCH_BREAKER_ENABLED, PUBLIC_ACCESS_REQUESTS_ENABLED — all on the backend compose environment: surface) are closed by the sibling backend-trio PR. This frontend PR is intentionally split out because the build-arg surface is a distinct fix shape.

Testing

  • tests/unit/test_1489_vite_bug_build_args.py — 7 passed locally.
  • Verified independently that all three defaulting layers agree on https://intake.abilityai.dev/v1/report-bug and true.

🤖 Generated with Claude Code


Folded-in dev test-hygiene fixes (pre-existing, not part of #1489)

Rebased onto dev's tip, which is currently red from two pre-existing failures unrelated to the VITE build-arg change. Folded their fixes here to keep dev green through the rebase:

  1. sys.modules lint (from feat(create): fork-to-own agent creation + brain-orb git-sync exemptions (trinity-enterprise#93, #76) #1490) — test_fork_to_own.py merged with 3 raw del sys.modules[...] and no baseline entry. Recorded them in tests/lint_sys_modules_baseline.txt (the lint's sanctioned escape hatch; zero test-behavior change). A snapshot/restore fixture was tried first but broke test_owner_mismatch_forbidden under full-suite ordering — reverted. Proper monkeypatch.delitem drain is a feat(create): fork-to-own agent creation + brain-orb git-sync exemptions (trinity-enterprise#93, #76) #1490-owned follow-up.
  2. test_login_rate_limit_split.py stub drift — its fake dependencies/models module stubs drifted behind routers/auth.py's imports (SEC: JWT Tokens Not Invalidated on Logout — no revocation mechanism #187 JWT-revocation added 4 dependencies names + models.User), erroring all 8 tests at fixture setup. Synced the stubs → 8 errors → 8 passed. No open issue existed; captured in the commit.

@AndriiPasternak31
AndriiPasternak31 requested review from dolho and vybe July 6, 2026 17:39
AndriiPasternak31 and others added 3 commits July 6, 2026 18:49
… as prod build args

HelpChatWidget (#1116) reads two build-time knobs to disable in-app bug
reporting or repoint it off the hosted intake, but the prod build path never
passed them. Vite inlines import.meta.env.* at build time, so an operator
setting VITE_BUG_REPORTING_ENABLED=false in .env had no effect — every prod
build shipped with reporting on, pointed at intake.abilityai.dev, with no
supported off switch.

Copy the existing VITE_API_URL plumbing verbatim: two ARG+ENV in
Dockerfile.prod (before npm run build), two build.args in
docker-compose.prod.yml, keeping compose default == ARG default == code
default so an unset .env byte-reproduces today. Document both in .env.example
with prod-only, no-secrets, and CSP-caveat warnings.

Repoint path is CSP-blocked (connect-src hard-codes the intake host in both
security-headers.conf and vite.config.js); disable path works end-to-end. CSP
parameterization for a working self-host repoint is an umbrella #1485 follow-up.

Fixes #1489
Refs #1485

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pure static tests (no Docker, no backend — mirroring
test_858_dockerfile_unbuffered.py) over the prod frontend build path:
Dockerfile.prod declares both ARG + ENV ${VAR} pass-throughs before
`RUN npm run build`, docker-compose.prod.yml forwards both via
${VAR:-default} build.args, and the three defaulting layers agree
(Dockerfile ARG == compose default == HelpChatWidget code default) so an
unset .env byte-reproduces today's behavior. Scoped to #1489; the general
VITE_* parity guard is a deferred #1485 follow-up.

Refs #1489, #1485

Co-Authored-By: Claude Opus 4.8 <[email protected]>
#1489)

Update the in-app-bug-reporting flow's Config-knobs bullet to record that the
#1116 build-time knobs are Vite build args (not runtime env) and are now plumbed
through docker/frontend/Dockerfile.prod + docker-compose.prod.yml with
three-layer default agreement; expand the CSP bullet with the repoint caveat.
Add a Recent Updates index row.

Refs #1489, #1485

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@AndriiPasternak31
AndriiPasternak31 force-pushed the AndriiPasternak31/issue-1489 branch from 45acf10 to 43badbe Compare July 6, 2026 17:51
@AndriiPasternak31

Copy link
Copy Markdown
Contributor Author

Heads-up @vybe: rebased onto latest dev and the sys.modules pollution lint went red — traced to #1490 (fork-to-own), whose tests/unit/test_fork_to_own.py merged with three bare del sys.modules['services.*'] and no baseline entry, so dev's own backend-unit-test tip is red and every open PR inherits it via the merge-ref.

Rather than block this frontend PR on it, I folded in the fix as commit 43badbed: added the linter's blessed snapshot/restore exemption pair (_STUBBED_MODULE_NAMES + autouse _restore_sys_modules, per the test_telegram_webhook_backfill.py precedent) — snapshots the services.*/database sys.modules subtrees around each test and restores after, so the dynamic per-test purges can't leak across the session. Behavior-preserving: the file's 40 tests still pass, lint now treats it as exempt. This also unbreaks dev's lint once merged. Shout if you'd rather own this as a separate #1490 follow-up and I'll drop the commit.

@AndriiPasternak31 AndriiPasternak31 self-assigned this Jul 6, 2026
AndriiPasternak31 and others added 2 commits July 6, 2026 19:04
…split with auth.py

Pre-existing dev-baseline failure (8 fixture errors, deterministic in isolation),
surfaced here because #1492's lint fix unmasks it in CI ordering. routers/auth.py
grew its imports over time but the fake-module stubs in this test drifted:

  - `from dependencies import (...)` gained get_current_user / is_token_revoked /
    oauth2_scheme / revoke_token_jti via the #187 JWT-revocation/logout work; the
    stub defined only authenticate_user + create_access_token.
  - `from models import User` (a Depends(get_current_user) param annotation on the
    #187 logout endpoint) was added; the models stub defined only Token.

`from dependencies import (...)` / `from models import (...)` resolve every name at
import time, so a missing stub attr errors the whole file at fixture setup. Add the
four dependencies stubs + the User stub (bare lambdas / a bare class — none are
exercised by the rate-limit paths under test). 8 errors -> 8 passed.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…wn (#1490)

PR #1490 (fork-to-own) merged tests/unit/test_fork_to_own.py with three raw
`del sys.modules['services.*']` and no baseline entry, reddening the sys.modules
pollution lint on dev's tip — every open PR inherits it via the merge-ref. This
PR rebased onto that tip, so record the three pre-existing violations in the lint
baseline to restore green.

Deliberately a baseline entry, NOT a code change: an autouse snapshot/restore
fixture (the lint's other sanctioned remedy) was tried first but re-adds modules a
test deliberately deletes, which broke test_owner_mismatch_forbidden under
full-suite ordering (regression-diff flagged it as a new HEAD failure). Baselining
touches zero test behavior and is the lint's explicit escape hatch for accepted
pre-existing debt. Properly draining these three to monkeypatch.delitem is a
#1490-owned follow-up for that file's author.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@AndriiPasternak31
AndriiPasternak31 force-pushed the AndriiPasternak31/issue-1489 branch from 43badbe to 6fd160e Compare July 6, 2026 18:04
@AndriiPasternak31

Copy link
Copy Markdown
Contributor Author

Update on the folded dev-hygiene fixes (revised from my earlier comment) @vybe @dolho:

1. sys.modules lint (from #1490). I first tried the autouse snapshot/restore fixture on test_fork_to_own.py — but under full-suite ordering it re-adds modules a test deliberately deletes and broke test_owner_mismatch_forbidden (the regression diff job flagged it as a new HEAD failure; it passed in isolation, failed in the 3561-test run). Reverted that and instead recorded the three pre-existing violations in tests/lint_sys_modules_baseline.txt — the lint's explicit escape hatch for accepted pre-existing debt, zero test-behavior change. @vybe, properly draining those three del sys.modules to monkeypatch.delitem in your file is a clean #1490 follow-up if you want it.

2. Second pre-existing dev failure unmasked. With the lint no longer gating ahead of pytest, test_login_rate_limit_split.py showed 8 fixture errors on dev's tip: routers/auth.py grew from dependencies import (…) (+4 names via #187 JWT-revocation) and from models import User, but the test's fake-module stubs still defined the old subset, so every test errored at import. Synced the stubs (bare lambdas + a bare User class; none exercised by the rate-limit paths). 8 errors → 8 passed.

Both are pre-existing on origin/dev (not caused by the VITE build-arg change) — folded here to keep dev green through the rebase. No issue existed for the login one; captured in the commit + here. Frontend #1489 change itself is unchanged.

@AndriiPasternak31
AndriiPasternak31 marked this pull request as ready for review July 6, 2026 18:12

@vybe vybe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Validated via /validate-pr: closing keyword ✅ (Fixes #1489), targets dev ✅, focused 8-file diff, security greps clean, feature-flow + .env.example updated, cross-layer default-agreement guard is exactly the right invariant. Ran the 15 touched unit tests locally — all pass (required checks don't run unit tests). Folded dev-hygiene fixes (sys.modules baseline for #1490 debt, auth stub sync) are justified — dev tip is red without them.

@vybe
vybe merged commit 998f9c5 into dev Jul 7, 2026
19 checks passed
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.

2 participants