fix(grz-tools): map duplicate tanG and upload errors correctly #617
Open
virag-compbio wants to merge 3 commits into
Open
fix(grz-tools): map duplicate tanG and upload errors correctly #617virag-compbio wants to merge 3 commits into
virag-compbio wants to merge 3 commits into
Conversation
tedil
reviewed
Jun 22, 2026
| assert len(result[0].states) >= 1 | ||
|
|
||
|
|
||
| def test_modify_submission_raises_on_duplicate_tan_g(db: SubmissionDb) -> None: |
Collaborator
There was a problem hiding this comment.
can you parameterize them so they're run both with sqlite and postgresql backends? see db_test_connection and pytest parametrize
tedil
requested changes
Jun 29, 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"], | ||
| ) |
Collaborator
There was a problem hiding this comment.
What I meant here was to perform the tests for both backends (sqlite and postgresql)
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.
Fixes:
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.
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.