You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: pass a payload that is not JSON to a custom mapper unchanged - #387
Before a mapper other than the rules-based one runs, Bitween parses the input as JSON to write in __partner__ and __globals__. On XML or CSV that parse threw, so the exchange failed before its mapper ran. Traxis prod hit it this morning: 854 SkyNet returns (XML, read by a custom mapper) failed with Unexpected character encountered while parsing value: <.
Now a payload that is not JSON is not enriched and reaches the mapper as it arrived, like a JSON array already did.
The golden files change only in === enriched, for the 20 inputs that are not valid JSON.
caveats.md and exchange-pipeline.md no longer describe the failure.
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
📜 Recent review details
⏰ Context from checks skipped due to timeout: 1
GitHub Check: build-and-unit-test
🔇 Additional comments: 1
SW.Bitween.Api/Services/MapperEnrichment.cs: 1
42-42: 🩺 Stability & Availability
The shared parser already handles parse failures.
ParsedPayload.TryGet catches parser exceptions, stores a failure sentinel, and returns false. The JsonReaderException catch in MapperEnrichment.Read then handles the fallback parse. The shared-parser path does not bypass this catch by throwing from TryGet.
📝 Summary
Summary
MapperEnrichment.Read now skips enrichment for invalid JSON.
Custom mappers receive XML, CSV, and other non-JSON payloads unchanged.
JSON object payloads still receive __partner__ and __globals__.
Documentation and golden files reflect this behavior.
Risk:risk:low
Security-sensitive areas: Existing enrichment can overwrite __partner__ and __globals__. No new security boundary changes.
Test coverage impact: Golden files cover malformed JSON, XML, CSV, BOM, and trailing-content inputs. Test execution results were not supplied.
Operational concerns: No migration or deployment steps are indicated. Rollback restores the previous preprocessing failures for non-JSON payloads.
MapperEnrichment.Read now returns null for JSON parse errors. Non-JSON payloads can proceed to custom mappers unchanged. Golden expectations and documentation reflect this behavior.
Changes: Mapper payload handling
Layer / File(s)
Summary
Enrichment handling and payload expectations SW.Bitween.Api/Services/MapperEnrichment.cs, SW.Bitween.Api/Services/XchangeService.cs, SW.Bitween.UnitTests/PayloadParsing/Golden/expected/*, docs/caveats.md, docs/exchange-pipeline.md
Read catches JsonReaderException and returns null. Comments clarify that only JSON objects are enriched. Golden expectations and documentation reflect handling of non-JSON payloads.
The intended non-JSON mapper behavior is consistently reflected in the implementation, tests, and documentation.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (22 skipped: …
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title clearly states the primary change: non-JSON payloads pass unchanged to custom mappers.
Description check
The description explains the prior JSON parsing failure, the new behavior, the production impact, and the related test and documentation updates.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage
Explanation
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (22 skipped: 22 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Fix all pre-merge checks with AI
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before a mapper other than the rules-based one runs, Bitween parses the input as JSON to write in
__partner__and__globals__. On XML or CSV that parse threw, so the exchange failed before its mapper ran. Traxis prod hit it this morning: 854 SkyNet returns (XML, read by a custom mapper) failed withUnexpected character encountered while parsing value: <.Now a payload that is not JSON is not enriched and reaches the mapper as it arrived, like a JSON array already did.
=== enriched, for the 20 inputs that are not valid JSON.caveats.mdandexchange-pipeline.mdno longer describe the failure.