Skip to content

fix(grz-tools): map duplicate tanG and upload errors correctly #617

Open
virag-compbio wants to merge 3 commits into
mainfrom
fix/grz-db-detect-postgres-tan-g-unique-violation
Open

fix(grz-tools): map duplicate tanG and upload errors correctly #617
virag-compbio wants to merge 3 commits into
mainfrom
fix/grz-db-detect-postgres-tan-g-unique-violation

Conversation

@virag-compbio

Copy link
Copy Markdown
Collaborator

Fixes:

  1. Duplicate tanG IntegrityError

Problem: modify_submission & update_submission caught IntegrityError but used a hardcoded string check for "submissions.tanG" - wrong case (should be tan_g) and PostgreSQL has a completely different error msg. So raw IntegrityError escaped and got mapped to UNKNOWN.

Fix: Added _is_tan_g_unique_violation() helper that handles both:

i) SQLite: "UNIQUE constraint failed: submissions.tan_g"
ii) PostgreSQL: inspects e.orig.diag.constraint_name == "ix_submissions_tan_g"

Both methods now call this. Tests added.

  1. UploadError

Problem: Two unrelated UploadError classes existed:

grz_common.exceptions.UploadError (imported by dbcontext)
grz_common.workers.upload.UploadError (actually raised by worker)

No inheritance --> isinstance() failed --> got mapped to UNKNOWN.

Fix: Removed the duplicate class from upload.py, replaced with from grz_common.exceptions import UploadError and updated worker.py imports.

@virag-compbio virag-compbio requested a review from tedil June 22, 2026 12:57
@virag-compbio virag-compbio changed the title fix: map duplicate tanG and upload errors correctly fix(grz-tools): map duplicate tanG and upload errors correctly Jun 22, 2026
assert len(result[0].states) >= 1


def test_modify_submission_raises_on_duplicate_tan_g(db: SubmissionDb) -> None:

@tedil tedil Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you parameterize them so they're run both with sqlite and postgresql backends? see db_test_connection and pytest parametrize

@virag-compbio virag-compbio self-assigned this Jun 24, 2026
Comment on lines +165 to +169
@pytest.mark.parametrize(
"set_tan_g",
[_set_tan_g_via_modify, _set_tan_g_via_update],
ids=["modify_submission", "update_submission"],
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I meant here was to perform the tests for both backends (sqlite and postgresql)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants