feat: validate clinical attribute values against the 255-character limit (#87)#158
Open
officialasishkumar wants to merge 1 commit into
Conversation
Clinical attribute values are stored in the `clinical_patient.ATTR_VALUE` and `clinical_sample.ATTR_VALUE` columns, which are defined as varchar(255). When a value exceeds this length it is silently truncated on load (for example, long free-text columns such as SURFACE_ANTIGENS_IMMUNOHISTOCHEMICAL_STAINS in the aml_ohsu_2022 study), resulting in loss of clinical detail without any feedback. Add a check in ClinicalValidator.checkLine() that raises an error when any clinical attribute value is longer than the maximum supported length, so the problem is surfaced during validation before the data is loaded. The check covers both sample- and patient-level clinical files. The 255-character limit is exposed as the MAX_CLINICAL_ATTRIBUTE_VALUE_LENGTH constant, mirroring the existing MAX_SAMPLE_STABLE_ID_LENGTH constant. Adds a unit test (and a data fixture) verifying the boundary: a value of exactly 255 characters is accepted while a 256-character value is rejected. Fixes cBioPortal#87
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.
Summary
Clinical attribute values longer than 255 characters are silently truncated on load, with no feedback from either the validator or the loader. For example, in the
aml_ohsu_2022study theSURFACE_ANTIGENS_IMMUNOHISTOCHEMICAL_STAINSvalue for sampleaml_ohsu_2022_2010_BA2304is cut off mid-sentence, losing clinical detail.The root cause is that clinical attribute values are stored in the
clinical_patient.ATTR_VALUEandclinical_sample.ATTR_VALUEcolumns, both defined asvarchar(255):Changes
MAX_CLINICAL_ATTRIBUTE_VALUE_LENGTH = 255, mirroring the existingMAX_SAMPLE_STABLE_ID_LENGTHconstant.ClinicalValidator.checkLine()(the base class shared bySampleClinicalValidatorandPatientClinicalValidator), raise an error when a value exceeds the maximum length, so the issue is caught during validation — before the data is loaded and truncated. This mirrors the existing 255-character check already applied toHGVSp_Shortin the mutation validator.data_clin_value_too_long.txt) verifying the boundary: a value of exactly 255 characters is accepted, while a 256-character value is rejected (reported with the correct line and column number).This addresses the validator side of the issue, which is the recommended gatekeeper in the import workflow (
validate → load): with validation enforcing the limit, the silent truncation is no longer reached through the normal pipeline.Test plan
Ran the full validator test suite (as in CI,
python:3.9):The new test:
Fixes #87