Proper handling of empty attribute when minLength=1
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
Ok, for our desired use case, this causes eido validation to fail:
_validate_sample_object(
File "/home/drc/GITHUB/looper/master/looper/venv/lib/python3.10/site-packages/eido/validation.py", line 100, in _validate_sample_object
_validate_object(sample.to_dict(), sample_schema_dict)
File "/home/drc/GITHUB/looper/master/looper/venv/lib/python3.10/site-packages/eido/validation.py", line 47, in _validate_object
instance_name = error.instance[sample_name_colname]
IndexError: string index out of range
This is because error.instance is empty and sample_name_colname=False
However, if you do have some value in the field such as 'h' but the minLength: 2, we see a better message:
Error: EidoValidationError (Validation failed): {"'h' is not valid under any of the given schemas": [{'type': "'h' is not valid under any of the given schemas", 'message': "'h' is not valid under any of the given schemas on instance h", 'sample_name': 'h'}]}
["'h' is not valid under any of the given schemas"]
Originally posted by @donaldcampbelljr in https://github.com/pepkit/looper/issues/523#issuecomment-2560016083
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in eido/validation.py, especially _validate_sample_object and _validate_object, and reproduce the empty-value case with minLength=1. Compare it with the non-empty minLength failure shown in the issue; done means empty attributes no longer trigger an IndexError and validation reports the failure consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100