Skip to content

fix(settings): allow owner require_open_shift PUT - #1120

Merged
khaira777 merged 2 commits into
mainfrom
fm/flocafe-issue-1072-r1
Oct 13, 2026
Merged

khaira777 merged 2 commits into
mainfrom
fm/flocafe-issue-1072-r1

Conversation

@khaira777

Copy link
Copy Markdown
Contributor

Intent

Verify and implement the surgical fix for FreeOpenSourcePOS/FloCafe issue #1072 ("Owner cannot update require_open_shift via settings API"): in main/routes/settings.ts, allow authorized owner/settings callers to update require_open_shift via PUT /api/settings/require_open_shift with strict Boolean representation ("true"/"false" or boolean true/false stored as "true"/"false") consistent with main/services/shift-session-gate.ts. Deliver via the no-mistakes pipeline as its own PR with Fixes #1072 in the PR summary.

What Changed

  • Added require_open_shift to ALLOWED_WILDCARD_KEYS in main/routes/settings.ts and validated PUT /api/settings/require_open_shift payloads to accept only boolean true/false or string "true"/"false", normalizing the persisted setting value to "true" or "false".
  • Updated tests/cash-sessions.test.ts to exercise PUT /api/settings/require_open_shift for role authorization (403 for cashier), invalid payload rejection (400), and toggling shift-session enforcement via boolean and string values (200).

Fixes #1072

Risk Assessment

✅ Low: The change is a small, well-bounded allowlist addition and strict boolean validation on PUT /api/settings/require_open_shift that matches shift-session-gate.ts and is covered by behavioral API tests.

Testing

Built the backend (npm run build), ran the focused integration test suites (npm run test:cash-sessions, npm run test:orders-layout-settings, and npm run test:theme-mode-settings), and stood up the compiled Express API server against an isolated SQLite database on port 34172 to drive all five happy-path, adversarial, and shift-gate enforcement scenarios live over HTTP, recording the full request/response and database state transcript in ~/.no-mistakes/evidence/01M4VBY10KF35JC378Q1E6PR5A/require-open-shift-live-api-transcript.json (backend API change only; no UI surface modified).

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Owner updates require_open_shift via PUT /api/settings/require_open_shift with string "true" and "false" and reads back persisted state via GET /api/settings/require_open_shift ✅ pass live ~/.no-mistakes/evidence/01M4VBY10KF35JC378Q1E6PR5A/require-open-shift-live-api-transcript.json
Owner updates require_open_shift via PUT /api/settings/require_open_shift with boolean true and false, persisting normalized "true" and "false" strings in SQLite ✅ pass live ~/.no-mistakes/evidence/01M4VBY10KF35JC378Q1E6PR5A/require-open-shift-live-api-transcript.json
Adversarial non-boolean payloads ("yes", "1", "0", "", 1, 0, null, {}) to PUT /api/settings/require_open_shift are rejected with HTTP 400 and do not mutate stored setting ✅ pass live ~/.no-mistakes/evidence/01M4VBY10KF35JC378Q1E6PR5A/require-open-shift-live-api-transcript.json
Adversarial cashier caller without settings.manage permission is rejected with HTTP 403 on PUT /api/settings/require_open_shift and stored setting remains unchanged ✅ pass live ~/.no-mistakes/evidence/01M4VBY10KF35JC378Q1E6PR5A/require-open-shift-live-api-transcript.json
Enabling require_open_shift via PUT /api/settings/require_open_shift blocks cash bill payments without an open shift (HTTP 409 cash_session_required), and disabling it via the API immediately allows c… ✅ pass live ~/.no-mistakes/evidence/01M4VBY10KF35JC378Q1E6PR5A/require-open-shift-live-api-transcript.json
Evidence: Live Express API & SQLite transcript for PUT /api/settings/require_open_shift

{ "serverPort": 34172, "stringToggle": { "s1_enable": { "status": 200, "dbValue": "true" }, "s1_get": { "status": 200, "value": "true" }, "s1_disable": { "status": 200, "dbValue": "false" } }, "booleanToggle": { "s2_enable": { "status": 200, "dbValue": "true" }, "s2_disable": { "status": 200, "dbValue": "false" } }, "invalidValuesRejected": ["yes", "1", "0", "", 1, 0, null, {}], "unauthorizedRoleRejected": { "status": 403, "permission": "settings.manage", "dbValue": "false" }, "shiftGateEnforcement": { "s5_payBlocked": { "status": 409, "display_code": "cash_session_required" }, "s5_payAllowed": { "status": 200, "payment_status": "paid" } } }

{
  "serverPort": 34172,
  "scenarios": {
    "stringToggle": {
      "s1_enable": {
        "status": 200,
        "body": {
          "setting": {
            "key": "require_open_shift",
            "value": "true",
            "updated_at": "2026-10-13 19:41:00"
          }
        },
        "dbValue": "true"
      },
      "s1_get": {
        "status": 200,
        "body": {
          "setting": {
            "key": "require_open_shift",
            "value": "true",
            "updated_at": "2026-10-13 19:41:00"
          }
        },
        "dbValue": "true"
      },
      "s1_disable": {
        "status": 200,
        "body": {
          "setting": {
            "key": "require_open_shift",
            "value": "false",
            "updated_at": "2026-10-13 19:41:00"
          }
        },
        "dbValue": "false"
      }
    },
    "booleanToggle": {
      "s2_enable": {
        "status": 200,
        "body": {
          "setting": {
            "key": "require_open_shift",
            "value": "true",
            "updated_at": "2026-10-13 19:41:00"
          }
        },
        "dbValue": "true"
      },
      "s2_disable": {
        "status": 200,
        "body": {
          "setting": {
            "key": "require_open_shift",
            "value": "false",
            "updated_at": "2026-10-13 19:41:00"
          }
        },
        "dbValue": "false"
      }
    },
    "invalidValuesRejected": [
      {
        "input": "yes",
        "status": 400,
        "body": {
          "error": "require_open_shift must be a boolean"
        },
        "dbValue": "false"
      },
      {
        "input": "1",
        "status": 400,
        "body": {
          "error": "require_open_shift must be a boolean"
        },
        "dbValue": "false"
      },
      {
        "input": "0",
        "status": 400,
        "body": {
          "error": "require_open_shift must be a boolean"
        },
        "dbValue": "false"
      },
      {
        "input": "",
        "status": 400,
        "body": {
          "error": "require_open_shift must be a boolean"
        },
        "dbValue": "false"
      },
      {
        "input": 1,
        "status": 400,
        "body": {
          "error": "require_open_shift must be a boolean"
        },
        "dbValue": "false"
      },
      {
        "input": 0,
        "status": 400,
        "body": {
          "error": "require_open_shift must be a boolean"
        },
        "dbValue": "false"
      },
      {
        "input": null,
        "status": 400,
        "body": {
          "error": "require_open_shift must be a boolean"
        },
        "dbValue": "false"
      },
      {
        "input": {},
        "status": 400,
        "body": {
          "error": "require_open_shift must be a boolean"
        },
        "dbValue": "false"
      }
    ],
    "unauthorizedRoleRejected": {
      "status": 403,
      "body": {
        "error": "Insufficient permissions",
        "code": "permission_denied",
        "permission": "settings.manage"
      },
      "dbValue": "false"
    },
    "shiftGateEnforcement": {
      "s5_gateOn": {
        "status": 200,
        "body": {
          "setting": {
            "key": "require_open_shift",
            "value": "true",
            "updated_at": "2026-10-13 19:41:01"
          }
        },
        "dbValue": "true"
      },
      "s5_payBlocked": {
        "status": 409,
        "body": {
          "error": "No open shift: open a shift before taking cash",
          "reason_code": "payment.invalid",
          "operation": "payment.create",
          "stage": "validation",
          "classification": "expected_rejection",
          "outcome": "not_applied",
          "correlation_id": "ab2583f1-f820-4826-b689-f4fd6c701ce9",
          "display_code": "cash_session_required"
        },
        "dbValue": "true"
      },
      "s5_gateOff": {
        "status": 200,
        "body": {
          "setting": {
            "key": "require_open_shift",
            "value": "false",
            "updated_at": "2026-10-13 19:41:01"
          }
        },
        "dbValue": "false"
      },
      "s5_payAllowed": {
        "status": 200,
        "body": {
          "bill": {
            "id": 1,
            "bill_number": "BILL-LIVE-1072",
            "order_id": 1,
            "customer_id": null,
            "subtotal": 50,
            "tax_amount": 0,
            "tax_breakdown": null,
            "tax_snapshot": null,
            "discount_amount": 0,
            "discount_type": null,
            "discount_value": null,
            "discount_reason": null,
            "delivery_charge": 0,
            "packaging_charge": 0,
            "service_charge": 0,
            "charges_breakdown": null,
            "round_off": 0,
            "total": 50,
            "paid_amount": 50,
            "balance": 0,
            "payment_status": "paid",
            "payment_details": [
              {
                "method": "cash",
                "cash_session_id": 0,
                "amount": 50,
                "requested_amount": 50,
                "amount_omitted": false,
                "tendered_amount": 50,
                "change_amount": 0,
                "timestamp": "2026-10-13 19:41:01"
              }
            ],
            "paid_at": "2026-10-13 19:41:01",
            "printed_at": null,
            "created_at": "2026-10-13T19:41:00.692Z",
            "updated_at": "2026-10-13 19:41:01",
            "split_group_id": null,
            "split_label": null
          },
          "walletDebited": false,
          "loyaltyPointsEarned": 0
        },
        "dbValue": "false"
      }
    }
  }
}

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Owner updates require_open_shift via PUT /api/settings/require_open_shift with string "true" and "false" and reads back persisted state via GET /api/settings/require_open_shift ✅ pass live ~/.no-mistakes/evidence/01M4VBY10KF35JC378Q1E6PR5A/require-open-shift-live-api-transcript.json
Owner updates require_open_shift via PUT /api/settings/require_open_shift with boolean true and false, persisting normalized "true" and "false" strings in SQLite ✅ pass live ~/.no-mistakes/evidence/01M4VBY10KF35JC378Q1E6PR5A/require-open-shift-live-api-transcript.json
Adversarial non-boolean payloads ("yes", "1", "0", "", 1, 0, null, {}) to PUT /api/settings/require_open_shift are rejected with HTTP 400 and do not mutate stored setting ✅ pass live ~/.no-mistakes/evidence/01M4VBY10KF35JC378Q1E6PR5A/require-open-shift-live-api-transcript.json
Adversarial cashier caller without settings.manage permission is rejected with HTTP 403 on PUT /api/settings/require_open_shift and stored setting remains unchanged ✅ pass live ~/.no-mistakes/evidence/01M4VBY10KF35JC378Q1E6PR5A/require-open-shift-live-api-transcript.json
Enabling require_open_shift via PUT /api/settings/require_open_shift blocks cash bill payments without an open shift (HTTP 409 cash_session_required), and disabling it via the API immediately allows c… ✅ pass live ~/.no-mistakes/evidence/01M4VBY10KF35JC378Q1E6PR5A/require-open-shift-live-api-transcript.json
  • npm run build
  • npm run test:cash-sessions
  • npm run test:orders-layout-settings
  • npm run test:theme-mode-settings
  • ELECTRON_RUN_AS_NODE=1 ./node_modules/.bin/electron -e '<live Express + SQLite verification on port 34172>'
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Allow authorized callers to update require_open_shift via PUT /api/settings/require_open_shift with strict boolean validation normalizing to 'true' or 'false'.

Fixes #1072
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository: FreeOpenSourcePOS/FloCafe/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7ddbf54d-2844-447b-a168-553a88819562

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@khaira777 khaira777 changed the title fix: allow updating require_open_shift via settings API fix(settings): allow owner require_open_shift PUT Oct 13, 2026
@khaira777

Copy link
Copy Markdown
Contributor Author

@greptile review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] This PR appears safe to merge; no actionable issues were found.

Summary

Allows callers with settings.manage to update require_open_shift through PUT /api/settings/require_open_shift.

  • Owners can now change the open-shift setting through the settings API.

Reviews (1) · Last reviewed commit: "fix(settings): allow updating require_op..." · Reviewed by Greptile

@khaira777
khaira777 enabled auto-merge (squash) October 13, 2026 20:51
@khaira777
khaira777 merged commit f55cb2f into main Oct 13, 2026
23 checks passed
@khaira777
khaira777 deleted the fm/flocafe-issue-1072-r1 branch October 13, 2026 20:58
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.

fix(settings): permit require_open_shift configuration via wildcard settings API

1 participant