fix: Prevent silent field overwrite when mapping conflicting fields to PostLabelingDelay#13
Open
Devguru-codes wants to merge 1 commit intoOSIPI:mainfrom
Open
fix: Prevent silent field overwrite when mapping conflicting fields to PostLabelingDelay#13Devguru-codes wants to merge 1 commit intoOSIPI:mainfrom
Devguru-codes wants to merge 1 commit intoOSIPI:mainfrom
Conversation
…o PostLabelingDelay
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In
ASLProcessor._rename_fields,field_mappingsmaps bothInversionTimeandInitialPostLabelDelaytoPostLabelingDelay. If a parsed session dict contains both fields with different values, the loop previously overwrote the first parsed mapping with the second mapping silently, resulting in data loss. This could silently change physical scan properties like PLD.Fix
Added a conflict detection check to the field mapping loop:
File Changed
package/src/pyaslreport/modalities/asl/processor.pyfor old_key, new_key in field_mappings.items(): if old_key in session: - session[new_key] = session[old_key] + if new_key in session and session[new_key] != session[old_key]: + import logging + logging.warning( + f"Field conflict: '{old_key}' ({session[old_key]}) maps to '{new_key}' " + f"which already has value {session[new_key]}. Retaining existing '{new_key}'." + ) + else: + session[new_key] = session[old_key] del session[old_key]API/Processor JSON Responses Comparison
When sending the following payload to the FastAPI
/api/report/process/bidsendpoint:{ "InversionTime": 1.5, "InitialPostLabelDelay": 2000.0, "RepetitionTime": 4000.0, "MagneticFieldStrength": 3.0, "MRAcquisitionType": "3D", "Manufacturer": "Generic" }mainbranch (before fix)The API normalizes the parameters silently losing the 1.5 value:
{ "MagneticFieldStrength": 3.0, "MRAcquisitionType": "3D", "Manufacturer": "Generic", "RepetitionTimePreparation": 4000.0, "PostLabelingDelay": 2000.0 }Result: The
InversionTimeof 1.5 is silently overwritten and lost.issue10branch (after fix)The API correctly spots the conflict and retains the first value (1.5), logging a warning:
{ "MagneticFieldStrength": 3.0, "MRAcquisitionType": "3D", "Manufacturer": "Generic", "RepetitionTimePreparation": 4000.0, "PostLabelingDelay": 1.5 }Server logs WARNING:
Python API Suite Results
mainbranch (before fix)Summary: PASSED=3 FAILED=1
issue10branch (after fix)Summary: PASSED=4 FAILED=0
Sanity Checks
Resolves #11