Skip to content

fix(addons): honor is_active on group create - #1111

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

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

Conversation

@khaira777

Copy link
Copy Markdown
Contributor

Intent

Verify and implement the surgical fix for FreeOpenSourcePOS/FloCafe issue #1064 ("persist is_active flag when creating addon groups"): in main/routes/addon-groups.ts, POST /api/addon-groups omits is_active from the INSERT INTO addon_groups statement, causing groups created with is_active: false to always be stored as active (1). Persist normalizeBoolean(is_active, true) ? 1 : 0 on group creation. Deliver via the no-mistakes pipeline as its own PR with Fixes #1064 in the PR summary so the issue and PR are linked.

What Changed

  • Updated POST /api/addon-groups in main/routes/addon-groups.ts to read is_active from the request body and persist normalizeBoolean(is_active, true) ? 1 : 0 in the INSERT INTO addon_groups statement.
  • Documented the is_active request body field for POST /api/addon-groups in docs/reference/api.md.
  • Extended tests/issue-245-246-addon-groups.test.ts to verify that POST /api/addon-groups defaults is_active to true (1) when omitted and persists false (0) when is_active: false is supplied.

Fixes #1064

Risk Assessment

✅ Low: Surgical fix that persists the normalized is_active flag on add-on group creation and adds direct API and database assertions.

Testing

Built the backend (npm run build), executed the targeted add-on group and inventory API test suites (test:issue-245-246-addon-groups, test:category-addon-groups, test:issue-244-product-addon-links, test:issue-125-addon-reads, test:addon-inventory-api), and stood up the compiled Express server against an isolated SQLite database to drive three live scenarios covering is_active: false creation, omitted is_active defaulting to true, and non-boolean falsy is_active inputs (0, "false") plus child-creation rejection on newly created inactive groups; all checks and scenarios passed. This is a backend API and SQLite persistence change with no UI surface change, so API/database evidence was captured in the evidence directory.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Create an inactive add-on group via POST /api/addon-groups with is_active: false and verify it persists as is_active = 0 in SQLite, is omitted from default GET /api/addon-groups, and is returned when… ✅ pass live ~/.no-mistakes/evidence/01M4V7CEBP30FFYACEPM80MPSR/issue-1064-live-api-verification.json
Create an add-on group via POST /api/addon-groups with is_active omitted and verify it defaults to active (is_active: true in response, is_active = 1 in SQLite, and visible in default GET /api/addon-g… ✅ pass live ~/.no-mistakes/evidence/01M4V7CEBP30FFYACEPM80MPSR/issue-1064-live-api-verification.json
Adversarial normalization and inactive-group guard: create add-on groups with non-boolean falsy representations (is_active: 0 and is_active: "false") and attempt POST /api/addon-groups/:id/addons agai… ✅ pass live ~/.no-mistakes/evidence/01M4V7CEBP30FFYACEPM80MPSR/issue-1064-live-api-verification.json
Evidence: Live API and SQLite verification transcript for POST /api/addon-groups is_active persistence

{ "serverPort": 3001, "scenario1_createInactiveBooleanFalse": { "postStatus": 201, "responseIsActive": false, "sqliteRow": { "id": "014a8e9b-d2bb-4662-8d5a-ccdf87156df6", "name": "Seasonal Toppings (Inactive)", "is_active": 0 }, "visibleInDefaultActiveList": false, "visibleInIncludeInactiveList": true }, "scenario2_createOmittedDefaultsToActive": { "postStatus": 201, "responseIsActive": true, "sqliteRow": { "id": "d267e70c-ac98-43b9-8398-0e050c3bebe4", "name": "Standard Milk Options", "is_active": 1 }, "visibleInDefaultActiveList": true }, "scenario3_adversarialFalsyAndInactiveGuard": { "numericZeroStatus": 201, "numericZeroResponseIsActive": false, "numericZeroSqliteRow": { "id": "2dc39d74-989a-4dfc-b8e7-5cc5d9895c84", "name": "Numeric Zero Inactive Group", "is_active": 0 }, "stringFalseStatus": 201, "stringFalseResponseIsActive": false, "stringFalseSqliteRow": { "id": "523ade03-a817-4272-8a7c-643149be4d0d", "name": "String False Inactive Group", "is_active": 0 }, "appendChildToNewlyCreatedInactiveGroup": { "status": 400, "data": { "error": "Cannot add add-ons to an inactive group" } } } }

{
  "serverPort": 3001,
  "scenario1_createInactiveBooleanFalse": {
    "postStatus": 201,
    "responseIsActive": false,
    "sqliteRow": {
      "id": "014a8e9b-d2bb-4662-8d5a-ccdf87156df6",
      "name": "Seasonal Toppings (Inactive)",
      "is_active": 0
    },
    "visibleInDefaultActiveList": false,
    "visibleInIncludeInactiveList": true
  },
  "scenario2_createOmittedDefaultsToActive": {
    "postStatus": 201,
    "responseIsActive": true,
    "sqliteRow": {
      "id": "d267e70c-ac98-43b9-8398-0e050c3bebe4",
      "name": "Standard Milk Options",
      "is_active": 1
    },
    "visibleInDefaultActiveList": true
  },
  "scenario3_adversarialFalsyAndInactiveGuard": {
    "numericZeroStatus": 201,
    "numericZeroResponseIsActive": false,
    "numericZeroSqliteRow": {
      "id": "2dc39d74-989a-4dfc-b8e7-5cc5d9895c84",
      "name": "Numeric Zero Inactive Group",
      "is_active": 0
    },
    "stringFalseStatus": 201,
    "stringFalseResponseIsActive": false,
    "stringFalseSqliteRow": {
      "id": "523ade03-a817-4272-8a7c-643149be4d0d",
      "name": "String False Inactive Group",
      "is_active": 0
    },
    "appendChildToNewlyCreatedInactiveGroup": {
      "status": 400,
      "data": {
        "error": "Cannot add add-ons to an inactive group"
      }
    }
  }
}
Evidence: Integration test suite output (tests/issue-245-246-addon-groups.test.ts)

> [email protected] test:issue-245-246-addon-groups
> node tests/run-electron-node-test.cjs tests/issue-245-246-addon-groups.test.ts

Integration Test: Issues #245/#246 add-on group invariants
==============================================================
[DB] Opening database at: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/flo-addon-groups-245-246-6HI6Cf/flo.db
[DB] Schema: v0 → v112
[DB] Triggering auto-backup before migrating v0 → v112...
[DB] Auto-backup before migrating v0 → v112 created at /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/flo-addon-groups-245-246-6HI6Cf/backups/flo-backup-2026-10-13T18-32-32-315Z-pre-v0-to-v112.db
[DB] Install defaults loaded; first-run setup pending
[MIGRATION v23] normalized: 0, unparseable: 0
[MIGRATION v23] merged 0 duplicate customer(s)
[MIGRATION v23] verification: 0 customers, 0 still non-E.164
[MIGRATION v24] normalized: 0, unparseable: 0
[MIGRATION v25] backfilled addons for 0 order items (0 unparseable, skipped)
[MIGRATION v30] backfilled 0 order_item(s) still missing a normalized addons snapshot
[MIGRATION v30] Dropped order_items.addons — order_item_addons is now the only place selected addons live.
[MIGRATION v73] normalized 0 merchant template payload(s); 0 already canonical or left untouched
[DB] integrity_check: ok
[DB] foreign_key_check: clean
[Auth] Generated new JWT secret for this install

─── Server-side validation ───
  ✓ blank add-on names and negative prices are rejected
  ✓ blank add-on name has a field error
  ✓ negative add-on price has a field error
  ✓ numeric is_active: 0 is treated as inactive for selection bounds
  ✓ valid add-on group is created
  ✓ group create defaults is_active to true when omitted
  ✓ omitted group is_active is stored as 1
  ✓ bulk create persists submitted inactive child state
  ✓ inactive add-on group is created
  ✓ group create response reflects is_active: false
  ✓ group create persists is_active: false as 0

─── Group edits preserve add-on identities ───
  ✓ bulk group edit succeeds
  ✓ existing add-on row is updated in place
  ✓ existing add-on price is updated
  ✓ existing add-on created_at is preserved
  ✓ existing add-on stays active
  ✓ omitted child is soft-deactivated instead of deleted
  ✓ new child is inserted when no id is supplied
  ✓ bulk group edit rejects foreign or unknown child ids

─── Inactive group child policy ───
  ✓ child create is rejected for inactive groups
[DB] Database closed

==============================================================
20/20 passed, 0 failed

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 - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Create an inactive add-on group via POST /api/addon-groups with is_active: false and verify it persists as is_active = 0 in SQLite, is omitted from default GET /api/addon-groups, and is returned when… ✅ pass live ~/.no-mistakes/evidence/01M4V7CEBP30FFYACEPM80MPSR/issue-1064-live-api-verification.json
Create an add-on group via POST /api/addon-groups with is_active omitted and verify it defaults to active (is_active: true in response, is_active = 1 in SQLite, and visible in default GET /api/addon-g… ✅ pass live ~/.no-mistakes/evidence/01M4V7CEBP30FFYACEPM80MPSR/issue-1064-live-api-verification.json
Adversarial normalization and inactive-group guard: create add-on groups with non-boolean falsy representations (is_active: 0 and is_active: "false") and attempt POST /api/addon-groups/:id/addons agai… ✅ pass live ~/.no-mistakes/evidence/01M4V7CEBP30FFYACEPM80MPSR/issue-1064-live-api-verification.json
  • npm run build
  • npm run test:issue-245-246-addon-groups
  • npm run test:category-addon-groups
  • npm run test:issue-244-product-addon-links
  • npm run test:issue-125-addon-reads
  • npm run test:addon-inventory-api
  • Live HTTP and SQLite verification against dist/main/server.js (POST /api/addon-groups, GET /api/addon-groups, GET /api/addon-groups?include_inactive=true, POST /api/addon-groups/:id/addons)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Persist normalizeBoolean(is_active, true) ? 1 : 0 when inserting into addon_groups in POST /api/addon-groups so groups created with is_active: false are stored as inactive.

Fixes #1064
@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: b86958ea-cb63-4ff9-8408-cae341894441

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: persist is_active flag when creating addon groups fix(addons): honor is_active on group create 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.

Summary

This PR fixes add-on group creation so the server saves the supplied is_active value.

  • New add-on groups keep the active state sent by callers.

No actionable issues found. This review checked code and tests; it did not run builds or test suites.

Reviews (1) · Last reviewed commit: "no-mistakes(document): docs: document is..." · Reviewed by Greptile

@khaira777
khaira777 merged commit 392231b into main Oct 13, 2026
24 checks passed
@khaira777
khaira777 deleted the fm/flocafe-issue-1064-r1 branch October 13, 2026 19:50
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(addon-groups): persist is_active flag when creating addon groups

1 participant