Skip to content

[Bug] Fix Page (/fix) Is Entirely Hardcoded Sample Data — No Backend Integration and Findings Selection Is Lost During Navigation #185

Description

@ionfwsrijan

Summary

The /fix page in the frontend (frontend/src/app/pages/fix.tsx) is completely disconnected from the backend. It renders hardcoded sample diffs and mock fix data. Users who select findings on the Findings page and click "Propose Fixes" are navigated to a page that shows predetermined fake data, not real remediation proposals. Furthermore, the selected finding IDs are not persisted or passed through navigation state, so even if the backend /fix endpoint were called, the frontend has lost the user's selection context.

Affected Files

  1. frontend/src/app/pages/fix.tsx — Entire file (lines 1–196). 100% hardcoded sample data, no API calls.
  2. frontend/src/app/pages/findings.tsx — "Propose Fixes" button navigation (line 450–451): <Link to="/fix"> with no state, query params, or context.
  3. frontend/src/app/lib/api.tsfix() function (lines 130–138) exists but is never called from any component.
  4. frontend/src/app/routes.ts — Fix route definition (line 17).
  5. backend/app/remediation/engine.py — The backend propose_fixes() function exists and works, but is unused by the frontend.

Root Cause

Issue A — No navigation state for selected findings

In findings.tsx line 450:

<Link to="/fix">
  <Button size="sm">Propose Fixes</Button>
</Link>

This is a plain <Link> with no state, no search params (e.g., ?findingIds=...), and no callback. The selectedFindings state (a Set<string>) exists in the Findings component but is never passed anywhere. When the user navigates to /fix, the Fix component has no idea which findings were selected.

Even if we fixed the Fix page to call the backend, it would call POST /fix with either no finding_ids or a hardcoded list, because the selection context is lost.

Issue B — Fix page is fully hardcoded

The Fix component (fix.tsx:31–52) defines its own inline array of fix objects:

const fixes = [
  {
    id: 0,
    title: "Fix SQL Injection in user query",
    severity: "critical",
    ...
    diff: sampleDiffs,  // hardcoded inline diff data
  },
  ...
];

It never:

  • Reads scan-store.ts for the current job_id
  • Calls api.fix(jobId, findingIds)
  • Parses URL params for findingIds
  • Displays real Fix objects from the backend response
  • Shows actual diffs — all DiffViewer data is fabricated

Issue C — Backend /fix endpoint is orphaned

The backend endpoint at POST /fix (main.py:609–619) works correctly, receiving FixRequest(job_id, finding_ids) and returning FixResponse(job_id, fixes). But no frontend code calls api.fix() on any page. The api.ts export of fix() is defined but has zero callers.

Expected Behavior

  1. When the user selects findings and clicks "Propose Fixes", the selected finding IDs must be passed to the /fix page.
  2. The /fix page should:
    • Read current job_id from scan-store.ts
    • Read selected finding IDs from navigation state or URL params
    • Call POST /fix with { job_id, finding_ids }
    • Display the returned Fix objects with real diffs, status, summaries, and notes
  3. The "Apply Patch" and "Verify" navigation should pass the applied fix IDs forward.
  4. If no findings are selected, the page should show a meaningful empty state.

Suggested Approach

  1. Change the "Propose Fixes" link in findings.tsx to pass selected IDs via React Router state or search params:
    <Link to="/fix" state={{ findingIds: [...selectedFindings] }}>
  2. Rewrite fix.tsx to:
    • Read state from useLocation()
    • If no state, read scan-store for job_id (but show error if no findings selected)
    • Call api.fix(jobId, findingIds) on mount
    • Render the real backend response
  3. Add loading, error, and empty states.
  4. Ensure the backend FixResponse.diff field is populated (currently always None for semgrep: and osv: finding types — engine.py:21,36 set diff=None). The engine needs to be enhanced to actually generate diffs.
  5. After applying a fix, navigate to /verify with the applied fix metadata.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions