Skip to content

fix: validate setup currencies against supported list - #839

Merged
khaira777 merged 1 commit into
mainfrom
codex/fix-835-setup-currency-validation
Sep 24, 2026
Merged

khaira777 merged 1 commit into
mainfrom
codex/fix-835-setup-currency-validation

Conversation

@khaira777

@khaira777 khaira777 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

What changed

First-run setup now validates currency input with the shared supported-currency list used by the currency-reset endpoint. Unsupported three-letter codes such as ZZZ return the existing 400 Invalid currency response before an owner is created.

Verification

  • npm run test:first-run
  • npm run test:currency
  • npm run test:security
  • npm run test:authz-phase3
  • npm run lint (passed with existing warnings)
  • npm run build
  • git diff --check

The full npm test suite was not run; this change is confined to first-run currency validation.

Closes #835.

Summary by CodeRabbit

  • Bug Fixes
    • First-time setup now rejects currency codes that are not supported, even when they have a valid three-letter format. The setup responds with an “Invalid currency” error instead of proceeding or failing unexpectedly, and does not create an account when the currency is unsupported.

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: FreeOpenSourcePOS/FloCafe/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 4a1104cf-77cb-4977-8d20-275599bda102

📥 Commits

Reviewing files that changed from the base of the PR and between ec08aa0 and 10b9404.

📒 Files selected for processing (2)
  • main/routes/auth.ts
  • tests/first-run-setup.test.ts

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The setup endpoint now validates normalized currencies against supported currency codes. The test suite checks that the endpoint rejects ZZZ with HTTP 400 and does not create a user.

Changes

Setup currency validation

Layer / File(s) Summary
Validate setup currencies
main/routes/auth.ts, tests/first-run-setup.test.ts
The setup route uses isSupportedCurrencyCode and returns HTTP 400 with Invalid currency for unsupported values. The new test checks rejection of ZZZ and confirms that no user is created.

Estimated code review effort: 2 (Simple) | ~8 minutes

Merge Risk: ⚪ Minimal · up to 10b94

Unsupported setup currencies receive the existing error response, and the added test covers ZZZ without creating an owner. No actionable merge-blocking risk is evident in the supplied change.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the behavior change and lists verification commands, but it omits most required template sections, including Scope, Compatibility & data safety, Screenshots, Cross-cutting sur… Complete the repository template. Add Related work, Summary, Scope, Compatibility & data safety, Screenshots, Cross-cutting surfaces, and Contributor checklist sections. Document command results and mark each applicable surface and checklis…
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: validating setup currencies against the supported currency list.
Linked Issues check ✅ Passed The PR meets the coding requirements in issue #835. main/routes/auth.ts now uses shared isSupportedCurrencyCode validation for setup initialization. tests/first-run-setup.test.ts verifies that u…
Out of Scope Changes check ✅ Passed The changed files support issue #835. The route change implements shared validation, and the test covers the required rejection behavior. No unrelated change is shown in the PR summary.
Full details: Description check

Explanation

The description explains the behavior change and lists verification commands, but it omits most required template sections, including Scope, Compatibility & data safety, Screenshots, Cross-cutting surfaces, and the Contributor checklist.

Resolution

Complete the repository template. Add Related work, Summary, Scope, Compatibility & data safety, Screenshots, Cross-cutting surfaces, and Contributor checklist sections. Document command results and mark each applicable surface and checklist item explicitly.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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 merged commit d1d5484 into main Sep 24, 2026
15 checks passed
@khaira777
khaira777 deleted the codex/fix-835-setup-currency-validation branch September 24, 2026 18:02
@itoqa

itoqa Bot commented Sep 24, 2026

Copy link
Copy Markdown

Ito QA test results
Commit: 10b9404: 8 test cases ran, 8 passed ✅.

Summary

Coverage spans first-run setup and persistence, including successful regional configuration, derived defaults, retry and rollback behavior, duplicate-owner prevention, and rejection of unsupported or malformed currency and business inputs. The results indicate healthy happy paths plus edge-case and adversarial validation with no observed application failures.

Safe to merge — the run found no regressions, new failures, or previously reported failures attributable to this PR, and all exercised behaviors completed successfully. No merge blocker is indicated; overall risk is low.

Tests run by Ito

View full run

Result Severity Type Description
✅ — General Setup accepted padded lowercase CAD and saved it as CAD. Blank, XXX, and XTS were rejected with the Invalid currency error, and no owner was created.
✅ — General An invalid business choice returned a clear error and created no owner or regional settings. After correcting the choice, setup succeeded and saved one owner with the expected Canada, CAD, and Vancouver settings.
✅ — General Setup with country CA and no currency succeeded and saved CAD. A request with no country returned a controlled 400 error and left the store without an owner or regional settings.
✅ — Currency The setup request with currency ZZZ returned a 400 Invalid currency response, and no owner was created.
✅ — Currency Submitting a number as the currency returned a controlled 400 Invalid currency response. No owner was created, and the setup screen remained available.
✅ — Rev The setup rejected the unsupported currency with a 400 error, left the fresh store empty, and then created one owner when retried with CAD.
✅ — Rev After the first owner was created, a second setup request was rejected with a 403 message and the original owner remained the only account.
✅ — Setup The fresh store accepted CAD setup and returned success. One owner was created, and the store kept Canada, CAD, America/Vancouver, and completed onboarding settings.

Tip

Reply with @itoqa to send us feedback on this test run.

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(auth): align currency validation in setup initialize with supported ISO list

1 participant