Location
package/src/pyaslreport/main.py:37 (get_bids_metadata)
package/src/pyaslreport/sequences/base_sequence.py
package/src/pyaslreport/sequences/siemens/asl/siemens_basic_single_pld.py
package/src/pyaslreport/sequences/ge/asl/ge_easl_multi_pld.py
Description
The DICOM processing endpoint expects get_bids_metadata() to return a tuple (metadata, asl_context). However, extract_bids_metadata() implementation varied across sequences: GE returned a tuple (metadata, asl_context), while Siemens returned only metadata (a dict). This inconsistency caused a ValueError: not enough values to unpack when processing Siemens DICOMs.
Reproduction (on main branch)
Reproducible Code (Python)
# reproduce_bug9.py — Run: .venv\Scripts\python.exe bug_9\reproduce_bug9.py
from pyaslreport.main import get_bids_metadata
from pyaslreport.enums.modaliy_enum import ModalityTypeValues
import unittest.mock as mock
# Mock headers for GE vs Siemens
# ...
with mock.patch('pyaslreport.main.get_dicom_header', return_value=siemens_header):
# This will crash with ValueError on main
metadata, asl_context = get_bids_metadata({"modality": ModalityTypeValues.ASL})
Script output on main branch
| # |
Test |
Status |
Detail |
| T1 |
GE extract_bids_metadata returns tuple |
PASS |
tuple |
| T2 |
Siemens extract_bids_metadata returns dict |
PASS |
dict |
| T3 |
get_bids_metadata for GE returns tuple |
PASS |
|
| T4 |
get_bids_metadata for Siemens returns tuple |
FAIL |
CRASH: not enough values to unpack |
Wait, why did T1/T2 pass on main? Because historically GE wrongly returned tuple, and Siemens correctly returned dict. The crash happens in T4 where get_bids_metadata tries to unpack the dict.
API Endpoint Reproduction
# api_reproduce_bug9.py — Shows 500 error on Siemens DICOM upload
from fastapi.testclient import TestClient
from app.main import app
client = TestClient(app, raise_server_exceptions=False)
# (Create mocked Siemens DICOM file test.dcm)
with open("test.dcm", "rb") as f:
file_content = f.read()
response = client.post(
"/api/report/process/dicom",
data={"modality": "ASL"},
files=[("upload_file", ("test.dcm", file_content, "application/dicom"))]
)
print(f"Status: {response.status_code}")
API Endpoint Responses on main
POST /api/report/process/dicom (Siemens DICOM)
Status: 500 Internal Server Error
Detail: "ValueError: not enough values to unpack (expected 2, got 1)"
>> VERDICT: Bug is PRESENT.
Note: This architectural fix follows the exact suggestion of mentor Jan Petr when this issue was originally raised by Devguru-codes in the previous repository (prior to OSIPI inclusion).
Location
package/src/pyaslreport/main.py:37(get_bids_metadata)package/src/pyaslreport/sequences/base_sequence.pypackage/src/pyaslreport/sequences/siemens/asl/siemens_basic_single_pld.pypackage/src/pyaslreport/sequences/ge/asl/ge_easl_multi_pld.pyDescription
The DICOM processing endpoint expects
get_bids_metadata()to return a tuple(metadata, asl_context). However,extract_bids_metadata()implementation varied across sequences: GE returned a tuple(metadata, asl_context), while Siemens returned onlymetadata(adict). This inconsistency caused aValueError: not enough values to unpackwhen processing Siemens DICOMs.Reproduction (on
mainbranch)Reproducible Code (Python)
Script output on
mainbranchWait, why did T1/T2 pass on main? Because historically GE wrongly returned tuple, and Siemens correctly returned dict. The crash happens in T4 where
get_bids_metadatatries to unpack the dict.API Endpoint Reproduction
API Endpoint Responses on
main