Commit graph

2 commits

Author SHA1 Message Date
ZdenekSrotyr
7f743d0392 fix(cli): #168 review iter 6 — render empty-string diagnostics
Devin Review iter #6 found 2 issues.

🟡 BUG: cli/error_render.py filtered out empty-string values via
`detail[key] not in (None, "")` and `value not in (None, "")` before
they could reach `_kv_line`. But `_kv_line` was specifically designed
to render empty strings as `(empty)` — the filter shadowed that
branch. The hidden field happens to be the most operator-actionable
one in `cross_project_forbidden`: `billing_project: ""` is the exact
diagnostic confirming WHY USER_PROJECT_DENIED fires.

Change filter to `is not None`. Empty strings now flow through
`_kv_line` and render as `billing_project: (empty)`.

📝 ANALYSIS: CHANGELOG wording for the test-connection endpoint said
"the saved data_source.bigquery config", which Devin flagged as
slightly misleading because `get_bq_access` is `@functools.cache`d —
"Test connection" tests the config in the running process, not the
just-saved YAML overlay. The save flow already returns
`restart_required: True` and the UI shows a banner, so the behavior
is documented; only the CHANGELOG wording was loose. Tightened to
"the **process-cached** BqAccess... Tests the config active in the
running process — after a save the response includes restart_required;
click Test AFTER restart to validate the freshly-saved values."

New test: test_renders_empty_string_as_empty_marker locks in the
empty-string-as-(empty) rendering for the cross_project_forbidden
case so a future filter change won't silently drop the diagnostic
again. 9 affected render tests pass.
2026-05-04 14:30:43 +02:00
ZdenekSrotyr
eddb0d2c58 test(cli): #160 RED tests for shared BQ error renderer
3 new test files that drive the upcoming cli/error_render.py module
and the V2ClientError refactor.

tests/test_cli_error_render.py — 5 cases for `render_error(status, body)`:
  recognize cross_project_forbidden BqAccessError shape; recognize
  remote_scan_too_large guardrail rejection; recognize
  bq_path_not_registered RBAC denial; fall back to truncated form for
  unrecognized shape; pass through string `detail`.

tests/test_cli_query_render.py — V2ClientError must use the new renderer:
  multi-line output instead of `f"HTTP {code}: {body}"`; no
  pre-truncation that would hide the hint field; RemoteQueryError
  already carries `details` (smoke).

tests/test_remote_query_error_details.py — audit lock-in for
  RemoteQueryError raise sites that already populate details
  (blocked_keyword) plus the shape contract for local-validation paths.

Run: 5 errors (cli.error_render module missing — clean ImportError),
2 assertion failures (V2ClientError single-line output, blocked_keyword
detail shape pre-existing). 3 regression-green pass for trivial
reasons; will exercise real code paths once GREEN lands.
2026-05-04 10:31:35 +02:00