pepkit / pepkit/eido

Proper handling of empty attribute when minLength=1

Open
#79 1 comment 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.