Skip to content

[Bug]: Default SAT3 instance uses stale format — 400 on problemInstance at load #125

Description

@wrigjl

Summary

On initial page load, the frontend issues a POST to ProblemProvider/problemInstance?problem=SAT3 using a hardcoded default instance that production no longer accepts, producing a 400.

Observed error

POST https://redux.isu.edu/api/redux/ProblemProvider/problemInstance?problem=SAT3  →  400

Response body from production:

{
  "error": "instance_parse_error",
  "problem": "3SAT",
  "expected": "Boolean formula in 3-CNF. Clauses joined by '&', literals within a clause joined by '|', negation prefix '!'. ...",
  "received": "{{1,2,3},{1,2},GENERIC}",
  "detail": "literal '{{1,2,3},{1,2},GENERIC}' is not a valid identifier (optionally prefixed with '!')"
}

Root cause

The default SAT3 instance is hardcoded in components/hooks/ProblemProvider/Problem.js:13:

[state.problemInstance, state.setProblemInstance] = useState("{{1,2,3},{1,2},GENERIC}");

Production's SAT3 no longer accepts this set-notation format. It expects a 3-CNF Boolean formula.

Proposed fix — seed from the backend, do not hardcode

The backend already publishes the correct default in its info payload, so we should never hardcode an instance literal (it inevitably drifts, as it has here). Example from production:

GET https://redux.isu.edu/api/redux/ProblemProvider/info?interface=SAT3
{
  "problemName": "3SAT",
  "defaultInstance": "(x1 | !x2 | x3) & (!x1 | x3 | x1) & (x2 | !x3 | !x1)",
  "instanceFormat": "Boolean formula in 3-CNF. ..."
}

Seed problemInstance from the selected problem's defaultInstance field (already fetched via requestInfoProblemProvider/info?interface=<problem>) instead of the hardcoded string. This makes the default correct for every problem, not just SAT3, and keeps the frontend in sync with backend format changes automatically.

Note: Problem.js:13 carries a comment warning that boot-up depends on this value being non-empty, so the seeding must preserve a defined initial value until the info fetch resolves.

Environment

Frontend (this repo) proxied to the production backend at https://redux.isu.edu.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions