Skip to content

fix: replace isPacs002Transaction gate with isStructuredTransaction#405

Merged
Justus-at-Tazama merged 2 commits intodevfrom
fix/isStructuredTransaction-guards
May 9, 2026
Merged

fix: replace isPacs002Transaction gate with isStructuredTransaction#405
Justus-at-Tazama merged 2 commits intodevfrom
fix/isStructuredTransaction-guards

Conversation

@Justus-at-Tazama
Copy link
Copy Markdown
Contributor

@Justus-at-Tazama Justus-at-Tazama commented May 9, 2026

Summary

Replaces the isPacs002Transaction outer gate with isStructuredTransaction as the umbrella guard for all ISO 20022 structured transaction types, with isPacs002Transaction retained as an inner narrowing guard for Pacs002-specific field access.

Also disables the @typescript-eslint/unified-signatures lint rule which crashes when it encounters a SupportedTransactionMessage union type parameter (bug in @typescript-eslint/eslint-plugin <= 8.46.2).

Changes

  • src/logic.service.ts - outer gate replaced with isStructuredTransaction, inner isPacs002Transaction guard retained for field access
  • __tests__/unit/logic.service.test.ts - new test: unsupported structured type (Pacs008) returns early
  • eslint.config.mjs - @typescript-eslint/unified-signatures disabled to work around linter crash
  • package.json - lib deps bumped to frms-coe-lib@8.0.0-rc.3 and frms-coe-startup-lib@3.0.2-rc.5

Related

Closes #404

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Improved transaction type validation and handling for better robustness.
  • Tests

    • Added test coverage for unsupported transaction type scenarios.
  • Chores

    • Updated dependencies to latest compatible versions.
    • Adjusted linting configuration for improved compatibility.

Review Change Stack

@Justus-at-Tazama Justus-at-Tazama requested review from a team as code owners May 9, 2026 22:45
@github-actions github-actions Bot added the bug label May 9, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

Warning

Rate limit exceeded

@Justus-at-Tazama has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 39 minutes and 48 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e33d1501-2e9f-4aad-b85e-06cbe9631529

📥 Commits

Reviewing files that changed from the base of the PR and between e9cabcb and 3e63250.

📒 Files selected for processing (1)
  • package.json
📝 Walkthrough

Walkthrough

This PR implements structured transaction type classification in handleTransaction using the isStructuredTransaction guard, adding early-exit logic for unsupported structured types, corresponding unit test coverage, and updating dependencies to newer rc versions alongside an ESLint rule fix.

Changes

Structured Transaction Type Handling

Layer / File(s) Summary
Type Guard Import
src/logic.service.ts
Added isStructuredTransaction to transaction-type utilities imported from @tazama-lf/frms-coe-lib.
Transaction ID Extraction Logic
src/logic.service.ts
Reworked handleTransaction to first check isStructuredTransaction; if structured, accept only PACS002 (else log "Unsupported structured transaction type" and return early); otherwise fall back to base-message ID extraction (or log "Unsupported transaction type" and return).
Test Unsupported Structured Type
__tests__/unit/logic.service.test.ts
Added unit test asserting early exit and no downstream calls (typology config, Redis/database, response handling) when receiving unsupported structured transaction pacs.008.001.10.
Dependencies & Tooling
eslint.config.mjs, package.json
Disabled @typescript-eslint/unified-signatures rule (crash on SupportedTransactionMessage union); bumped @tazama-lf/frms-coe-lib to ^8.0.0-rc.3 and @tazama-lf/frms-coe-startup-lib to ^3.0.2-rc.5.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

  • Directly implements the porting requirements from linked issue #404: bumps frms-coe-lib to 8.0.0-rc.3 and uses isStructuredTransaction guard for transaction classification in handleTransaction.

Possibly related PRs

  • tazama-lf/typology-processor#394: Both PRs modify src/logic.service.ts transaction-classification and ID-extraction logic by introducing/using type-guards to distinguish structured vs base/PACS002 messages.

Suggested labels

enhancement

Poem

🐰 Structured types now find their place,
No more crashes in the race,
Early exits, guards in hand,
Messages flow just as planned!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: replacing isPacs002Transaction with isStructuredTransaction as the outer type-guard for handling ISO 20022 structured transactions.
Linked Issues check ✅ Passed The PR meets all coding requirements from #404: library bump to 8.0.0-rc.3 completed [#404], type-guard pattern ported with isStructuredTransaction as outer gate and isPacs002Transaction retained for field access [#404], and unsupported structured type handling added with test coverage.
Out of Scope Changes check ✅ Passed All changes align with #404 objectives: library updates, logic.service.ts refactoring, test addition, and ESLint configuration for a documented crash workaround are all within scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/isStructuredTransaction-guards

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/logic.service.ts (1)

191-197: ⚡ Quick win

Include transaction type in the error message for better debugging.

The error log at line 195 uses a static message without including the actual transaction type. Adding the transaction type (e.g., parsedTrans.TxTp) would help operators identify which structured types are being received but not supported.

♻️ Suggested improvement
     if (isPacs002Transaction(transaction)) {
       transactionId = transaction.FIToFIPmtSts.GrpHdr.MsgId;
     } else {
-      loggerService.error('Unsupported structured transaction type', new Error('Unsupported structured transaction type'), context);
+      loggerService.error(`Unsupported structured transaction type: ${parsedTrans.TxTp}`, new Error(`Unsupported structured transaction type: ${parsedTrans.TxTp}`), context);
       return;
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/logic.service.ts` around lines 191 - 197, The error log in the
isStructuredTransaction branch uses a static message; update the
loggerService.error call in the block guarded by isStructuredTransaction /
isPacs002Transaction so it includes the actual structured transaction type
(e.g., parsedTrans.TxTp or transaction.TxTp) in the message and/or Error object;
locate the conditional using isStructuredTransaction and isPacs002Transaction
and change the loggerService.error('Unsupported structured transaction type',
new Error(...), context) to include the transaction type value and a clear
message referencing transactionId/transaction or parsedTrans so operators can
see which TxTp was unsupported.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@package.json`:
- Around line 39-40: The package.json lists non-published release-candidate
versions for dependencies `@tazama-lf/frms-coe-lib` and
`@tazama-lf/frms-coe-startup-lib` which fail install; update the version strings
for these identifiers to valid published versions (or remove the -rc suffix and
pin to the latest stable) in package.json, then run npm info or npm view for
`@tazama-lf/frms-coe-lib` and `@tazama-lf/frms-coe-startup-lib` to confirm the
chosen versions exist and run npm install to verify resolution before merging.

---

Nitpick comments:
In `@src/logic.service.ts`:
- Around line 191-197: The error log in the isStructuredTransaction branch uses
a static message; update the loggerService.error call in the block guarded by
isStructuredTransaction / isPacs002Transaction so it includes the actual
structured transaction type (e.g., parsedTrans.TxTp or transaction.TxTp) in the
message and/or Error object; locate the conditional using
isStructuredTransaction and isPacs002Transaction and change the
loggerService.error('Unsupported structured transaction type', new Error(...),
context) to include the transaction type value and a clear message referencing
transactionId/transaction or parsedTrans so operators can see which TxTp was
unsupported.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 66921bea-a32d-4e10-982d-5a9b3e049858

📥 Commits

Reviewing files that changed from the base of the PR and between 6d873df and e9cabcb.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • __tests__/unit/logic.service.test.ts
  • eslint.config.mjs
  • package.json
  • src/logic.service.ts

Comment thread package.json Outdated
@Justus-at-Tazama Justus-at-Tazama merged commit 9ef7734 into dev May 9, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant