Skip to content
This repository was archived by the owner on Apr 21, 2026. It is now read-only.

fix: harden siza production blockers and audit gating#481

Merged
LucasSantana-Dev merged 2 commits intomainfrom
fix/siza-prod-blockers-hotfix
Mar 12, 2026
Merged

fix: harden siza production blockers and audit gating#481
LucasSantana-Dev merged 2 commits intomainfrom
fix/siza-prod-blockers-hotfix

Conversation

@LucasSantana-Dev
Copy link
Copy Markdown
Member

@LucasSantana-Dev LucasSantana-Dev commented Mar 12, 2026

Summary

  • fix generation auth contract so unauthenticated requests return 401 (not 500) for /api/generations, /api/generations/history, and /api/generations/[id]
  • fix roadmap mobile overflow risk by updating PhaseCard header wrapping and enabling roadmap page overflow-x-hidden
  • align lead-readiness checkout smoke with billing feature flag (accept 403 Billing is not enabled when disabled)
  • add production audit harness (test:e2e:prod, production Playwright config, public smoke spec)
  • harden e2e-production-audit.sh to use real runtime probes only and map fix targets correctly
  • update README + CHANGELOG

Validation

  • npm run lint (apps/web) ✅
  • npm run test -- src/app/api/generations/__tests__/route.test.ts src/app/api/generations/history/__tests__/route.test.ts
  • npm run test -- --runTestsByPath 'src/app/api/generations/[id]/__tests__/route.test.ts'
  • PROD_E2E_SCOPE=public npm run test:e2e:prod ✅ harness execution + issues-map generation (expected fail on current prod roadmap/auth until deploy)

Notes

  • production probe evidence (current live behavior before deploy):
    • /api/generations -> 500
    • /api/generations/history -> 500
    • /api/generations/nonexistent-id -> 500
    • /roadmap mobile overflow test fails

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Fixed horizontal overflow issue on the roadmap page when viewed on mobile devices.
    • Improved error handling for Stripe checkout when billing is disabled.
  • Tests

    • Added comprehensive production smoke tests for public pages (gallery, sign-in, sign-up, forgot-password, and roadmap).
    • Introduced production end-to-end testing suite to ensure stability across critical user-facing pages.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
siza-web Ready Ready Preview, Comment Mar 12, 2026 11:09pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 12, 2026

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

This PR introduces production E2E testing infrastructure with Playwright configuration and orchestration scripts, refactors API error handling for generations endpoints with a centralized error handler, adds API authentication contract tests, and updates roadmap UI components with layout and overflow fixes.

Changes

Cohort / File(s) Summary
Production E2E Testing Infrastructure
apps/web/e2e/production-public-smoke.spec.ts, apps/web/playwright.production.config.ts, apps/web/scripts/e2e-production-audit.sh, apps/web/package.json
New Playwright test suite with five public-page smoke tests (gallery, sign-in, sign-up, forgot-password, roadmap mobile overflow). Includes production Playwright config with environment-driven reporting, non-parallel execution, and Chromium project. Adds orchestration script that handles environment resolution, Supabase/Vercel integration, test execution per pack, and issues aggregation. Introduces new npm script test:e2e:prod.
API Error Handling Refactoring
apps/web/src/app/api/generations/error-handler.ts, apps/web/src/app/api/generations/route.ts, apps/web/src/app/api/generations/[id]/route.ts, apps/web/src/app/api/generations/history/route.ts
New centralized error handler module that consolidates 401/500 error responses for generations endpoints. Replaces direct captureServerError calls and generic error responses in three route files with unified handleGenerationRouteError invocations.
API Authentication Contract Tests
apps/web/src/app/api/generations/__tests__/auth-contract.test.ts
New test suite validating authentication contract across generations endpoints (list, history, by-id). Mocks rate-limiting and Sentry; verifies 401 responses with appropriate error messages when verifySession is unauthorized.
Roadmap UI Updates
apps/web/src/app/(marketing)/roadmap/roadmap-client.tsx, apps/web/src/components/roadmap/PhaseCard.tsx
Adds overflow-x-hidden CSS class to roadmap client root. Restructures PhaseCard layout from single-row to two-column responsive design with phase number/title in left column and date/chevron in right column; updates badge styling and adds data-testid for test selection.
Lead Readiness Test Enhancement
apps/web/e2e/lead-readiness.spec.ts
Modified Stripe checkout session test to explicitly handle 403 billing-disabled status by parsing response and asserting error message equals "Billing is not enabled", then returning early; otherwise validates 200 response with non-empty URL.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective of the PR: hardening production blockers and audit gating, which aligns with the core fixes for auth contract, roadmap overflow, billing feature gating, and the new production audit harness.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/siza-prod-blockers-hotfix
📝 Coding Plan
  • Generate coding plan for human review comments

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 OpenGrep (1.16.4)
apps/web/src/app/api/generations/error-handler.ts

┌──────────────┐
│ Opengrep CLI │
└──────────────┘

�[32m✔�[39m �[1mOpengrep OSS�[0m
�[32m✔�[39m Basic security coverage for first-party code vulnerabilities.

�[1m Loading rules from local config...�[0m

apps/web/src/app/api/generations/__tests__/auth-contract.test.ts

┌──────────────┐
│ Opengrep CLI │
└──────────────┘

�[32m✔�[39m �[1mOpengrep OSS�[0m
�[32m✔�[39m Basic security coverage for first-party code vulnerabilities.

�[1m Loading rules from local config...�[0m

apps/web/src/app/api/generations/[id]/route.ts

┌──────────────┐
│ Opengrep CLI │
└──────────────┘

�[32m✔�[39m �[1mOpengrep OSS�[0m
�[32m✔�[39m Basic security coverage for first-party code vulnerabilities.

�[1m Loading rules from local config...�[0m

  • 2 others

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 12, 2026

Project Scorecard


Scorecard: 84/100 (B)
────────────────────────────────────────
  security: 100/100 (A)
  quality: 80/100 (B) — 1 violations
  performance: 67/100 (D) — 1 violations
  compliance: 75/100 (C) — 1 violations
  dependency: 100/100 (A)

Recommendations:
  - Increase test coverage to meet the 80% threshold
  - Extend log retention to at least 90 days for compliance

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (4)
apps/web/scripts/e2e-production-audit.sh (4)

42-82: Apply the same [[ conditional pattern to remaining functions.

These functions also use [ conditionals that should be updated to [[ for consistency and safety.

♻️ Proposed fixes
 resolve_service_role_key() {
-  if [ -n "${SUPABASE_SERVICE_ROLE_KEY:-}" ]; then
+  if [[ -n "${SUPABASE_SERVICE_ROLE_KEY:-}" ]]; then
     return
   fi
 
   local url="${NEXT_PUBLIC_SUPABASE_URL:-}"
-  if [ -z "${url}" ]; then
+  if [[ -z "${url}" ]]; then
     return
   fi
 
   local project_ref
   project_ref="$(echo "${url}" | sed -E 's#https?://([^.]+).*#\1#')"
-  if [ -z "${project_ref}" ]; then
+  if [[ -z "${project_ref}" ]]; then
     return
   fi
 
   local resolved
   resolved="$(
     supabase projects api-keys --project-ref "${project_ref}" --output json 2>/dev/null \
       | jq -r '.[] | select(.name=="service_role") | .api_key // empty' \
       | head -n 1
   )"
 
-  if [ -n "${resolved}" ]; then
+  if [[ -n "${resolved}" ]]; then
     export SUPABASE_SERVICE_ROLE_KEY="${resolved}"
   fi
 }
 
 resolve_vercel_env_dir() {
   local common_git_dir
   common_git_dir="$(git -C "${REPO_DIR}" rev-parse --path-format=absolute --git-common-dir 2>/dev/null || true)"
-  if [ -n "${common_git_dir}" ]; then
+  if [[ -n "${common_git_dir}" ]]; then
     local canonical_repo_dir
     canonical_repo_dir="$(cd "${common_git_dir}/.." && pwd)"
-    if [ -f "${canonical_repo_dir}/.vercel/project.json" ]; then
+    if [[ -f "${canonical_repo_dir}/.vercel/project.json" ]]; then
       echo "${canonical_repo_dir}"
       return
     fi
   fi
   echo "${REPO_DIR}"
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web/scripts/e2e-production-audit.sh` around lines 42 - 82, Update the
conditional tests in resolve_service_role_key and resolve_vercel_env_dir to use
the Bash [[ ... ]] syntax instead of [ ... ] for safer, more consistent
conditionals: change all occurrences like if [ -n "${VAR}" ]; then and if [ -z
"${VAR}" ]; then to if [[ -n "${VAR}" ]]; then / if [[ -z "${VAR}" ]]; then, and
change the file test if [ -f "${canonical_repo_dir}/.vercel/project.json" ];
then to if [[ -f "${canonical_repo_dir}/.vercel/project.json" ]]; then; keep the
existing logic and variable names (SUPABASE_SERVICE_ROLE_KEY,
NEXT_PUBLIC_SUPABASE_URL, project_ref, resolved, common_git_dir,
canonical_repo_dir, REPO_DIR, resolve_service_role_key, resolve_vercel_env_dir)
unchanged.

270-278: Apply [[ conditionals and stderr redirect to run_pack function.

♻️ Proposed fixes
   local playwright_bin="${WEB_DIR}/node_modules/.bin/playwright"
-  if [ ! -x "${playwright_bin}" ]; then
+  if [[ ! -x "${playwright_bin}" ]]; then
     playwright_bin="${REPO_DIR}/node_modules/.bin/playwright"
   fi
 
-  if [ ! -x "${playwright_bin}" ]; then
-    echo "[ERROR] Playwright binary not found."
+  if [[ ! -x "${playwright_bin}" ]]; then
+    echo "[ERROR] Playwright binary not found." >&2
     exit 1
   fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web/scripts/e2e-production-audit.sh` around lines 270 - 278, In the
run_pack function update the file-existence checks to use Bash [[ ]]
conditionals for portability and safety (replace if [ ! -x "${playwright_bin}"
]; then ... fi with if [[ ! -x "${playwright_bin}" ]]; then ... fi) and ensure
error messages go to stderr by redirecting echoes (use echo "[ERROR] Playwright
binary not found." >&2) and exits remain the same; apply these changes around
the playwright_bin resolution logic inside run_pack so the checks use [[ ]] and
error output is redirected to stderr.

18-40: Consider using [[ for conditional tests and redirecting errors to stderr.

Static analysis flagged multiple instances where [ is used instead of [[ for conditional tests, and error messages should be redirected to stderr. While functional, [[ is safer in bash (handles word splitting and globbing better), and stderr is the appropriate channel for error output.

♻️ Proposed fixes for shell best practices
 require_env() {
   local name="$1"
-  if [ -z "${!name:-}" ]; then
-    echo "[ERROR] Missing required env: ${name}"
+  if [[ -z "${!name:-}" ]]; then
+    echo "[ERROR] Missing required env: ${name}" >&2
     exit 1
   fi
+  return 0
 }
 
 ensure_non_local_supabase() {
   local url="${NEXT_PUBLIC_SUPABASE_URL:-}"
   if [[ "${url}" == *"localhost"* || "${url}" == *"127.0.0.1"* ]]; then
-    echo "[ERROR] NEXT_PUBLIC_SUPABASE_URL must be non-local for production audit."
+    echo "[ERROR] NEXT_PUBLIC_SUPABASE_URL must be non-local for production audit." >&2
     exit 1
   fi
+  return 0
 }
 
 ensure_generation_backend() {
-  if [ -n "${MCP_GATEWAY_URL:-}" ] || [ -n "${GEMINI_API_KEY:-}" ] || [ -n "${OPENAI_API_KEY:-}" ] || [ -n "${ANTHROPIC_API_KEY:-}" ]; then
+  if [[ -n "${MCP_GATEWAY_URL:-}" ]] || [[ -n "${GEMINI_API_KEY:-}" ]] || [[ -n "${OPENAI_API_KEY:-}" ]] || [[ -n "${ANTHROPIC_API_KEY:-}" ]]; then
     return
   fi
-  echo "[ERROR] Missing generation backend (set MCP_GATEWAY_URL or one AI provider key)."
+  echo "[ERROR] Missing generation backend (set MCP_GATEWAY_URL or one AI provider key)." >&2
   exit 1
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web/scripts/e2e-production-audit.sh` around lines 18 - 40, Update the
three helper functions to use bash [[ ]] conditionals and send error messages to
stderr: in require_env replace the [ -z "${!name:-}" ] test with [[ -z
"${!name:-}" ]] and write the echo error to >&2 before exiting; in
ensure_non_local_supabase use [[ "${url}" == *localhost* || "${url}" ==
*127.0.0.1* ]] and echo the error to >&2; in ensure_generation_backend use [[ -n
"${MCP_GATEWAY_URL:-}" || -n "${GEMINI_API_KEY:-}" || -n "${OPENAI_API_KEY:-}"
|| -n "${ANTHROPIC_API_KEY:-}" ]] and echo its error to >&2 — keep the same exit
codes and preserve variable quoting when referencing NEXT_PUBLIC_SUPABASE_URL
and parameter expansion like ${!name:-}.

334-337: Redirect error message to stderr.

♻️ Proposed fix
   *)
-    echo "[ERROR] Invalid PROD_E2E_SCOPE: ${SCOPE} (use all|public|auth)"
+    echo "[ERROR] Invalid PROD_E2E_SCOPE: ${SCOPE} (use all|public|auth)" >&2
     exit 1
     ;;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web/scripts/e2e-production-audit.sh` around lines 334 - 337, The error
message in the default case currently prints to stdout; change the echo in the
case '*' block that references SCOPE/PROD_E2E_SCOPE to write to stderr instead
(e.g., use redirection so the "[ERROR] Invalid PROD_E2E_SCOPE: ${SCOPE} (use
all|public|auth)" message goes to stderr) and keep the exit 1 unchanged; update
the case '*' branch where SCOPE is checked so the error output is redirected to
stderr.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/web/scripts/e2e-production-audit.sh`:
- Around line 42-82: Update the conditional tests in resolve_service_role_key
and resolve_vercel_env_dir to use the Bash [[ ... ]] syntax instead of [ ... ]
for safer, more consistent conditionals: change all occurrences like if [ -n
"${VAR}" ]; then and if [ -z "${VAR}" ]; then to if [[ -n "${VAR}" ]]; then / if
[[ -z "${VAR}" ]]; then, and change the file test if [ -f
"${canonical_repo_dir}/.vercel/project.json" ]; then to if [[ -f
"${canonical_repo_dir}/.vercel/project.json" ]]; then; keep the existing logic
and variable names (SUPABASE_SERVICE_ROLE_KEY, NEXT_PUBLIC_SUPABASE_URL,
project_ref, resolved, common_git_dir, canonical_repo_dir, REPO_DIR,
resolve_service_role_key, resolve_vercel_env_dir) unchanged.
- Around line 270-278: In the run_pack function update the file-existence checks
to use Bash [[ ]] conditionals for portability and safety (replace if [ ! -x
"${playwright_bin}" ]; then ... fi with if [[ ! -x "${playwright_bin}" ]]; then
... fi) and ensure error messages go to stderr by redirecting echoes (use echo
"[ERROR] Playwright binary not found." >&2) and exits remain the same; apply
these changes around the playwright_bin resolution logic inside run_pack so the
checks use [[ ]] and error output is redirected to stderr.
- Around line 18-40: Update the three helper functions to use bash [[ ]]
conditionals and send error messages to stderr: in require_env replace the [ -z
"${!name:-}" ] test with [[ -z "${!name:-}" ]] and write the echo error to >&2
before exiting; in ensure_non_local_supabase use [[ "${url}" == *localhost* ||
"${url}" == *127.0.0.1* ]] and echo the error to >&2; in
ensure_generation_backend use [[ -n "${MCP_GATEWAY_URL:-}" || -n
"${GEMINI_API_KEY:-}" || -n "${OPENAI_API_KEY:-}" || -n "${ANTHROPIC_API_KEY:-}"
]] and echo its error to >&2 — keep the same exit codes and preserve variable
quoting when referencing NEXT_PUBLIC_SUPABASE_URL and parameter expansion like
${!name:-}.
- Around line 334-337: The error message in the default case currently prints to
stdout; change the echo in the case '*' block that references
SCOPE/PROD_E2E_SCOPE to write to stderr instead (e.g., use redirection so the
"[ERROR] Invalid PROD_E2E_SCOPE: ${SCOPE} (use all|public|auth)" message goes to
stderr) and keep the exit 1 unchanged; update the case '*' branch where SCOPE is
checked so the error output is redirected to stderr.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a988fa9e-1b3c-46af-a64a-b7ed54b3cba1

📥 Commits

Reviewing files that changed from the base of the PR and between a3e0ef8 and f40c9a7.

⛔ Files ignored due to path filters (2)
  • CHANGELOG.md is excluded by !**/*.md
  • README.md is excluded by !**/*.md
📒 Files selected for processing (13)
  • apps/web/e2e/lead-readiness.spec.ts
  • apps/web/e2e/production-public-smoke.spec.ts
  • apps/web/package.json
  • apps/web/playwright.production.config.ts
  • apps/web/scripts/e2e-production-audit.sh
  • apps/web/src/app/(marketing)/roadmap/roadmap-client.tsx
  • apps/web/src/app/api/generations/[id]/__tests__/route.test.ts
  • apps/web/src/app/api/generations/[id]/route.ts
  • apps/web/src/app/api/generations/__tests__/route.test.ts
  • apps/web/src/app/api/generations/history/__tests__/route.test.ts
  • apps/web/src/app/api/generations/history/route.ts
  • apps/web/src/app/api/generations/route.ts
  • apps/web/src/components/roadmap/PhaseCard.tsx

@sonarqubecloud
Copy link
Copy Markdown

@LucasSantana-Dev LucasSantana-Dev merged commit fe1cb02 into main Mar 12, 2026
21 of 22 checks passed
@LucasSantana-Dev LucasSantana-Dev deleted the fix/siza-prod-blockers-hotfix branch March 12, 2026 23:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant