fix: replace bare excepts in tg-set-prompt, structured-data cleanup and API docs generator - #1114
Closed
Thorsrud22 wants to merge 1 commit into
Closed
Thorsrud22 wants to merge 1 commit into
Thorsrud22 wants to merge 1 commit into
Conversation
Contributor License AgreementThank you for your contribution! Before we can accept it, the following contributor(s) must sign our CLA: Please read the appropriate agreement:
Once you have read the appropriate agreement, post the following as a comment on this PR (copy and paste exactly): The bot will record your signature and update this PR automatically. |
…nd API docs generator Three of the remaining bare `except:` clauses from trustgraph-ai#783, each swallowing KeyboardInterrupt and SystemExit: - trustgraph-cli/trustgraph/cli/set_prompt.py: the --schema JSON parse now catches json.JSONDecodeError only, and chains it onto the RuntimeError so the parse position is not lost. - trustgraph-cli/trustgraph/cli/load_structured_data.py: the temp descriptor cleanup catches OSError only. - docs/generate-api-docs.py: the inspect.signature fallback catches the two errors it actually raises, TypeError and ValueError. Tests for tg-set-prompt cover the invalid-JSON error message, a valid schema being passed through, and KeyboardInterrupt propagating out of the parse. Refs trustgraph-ai#783
Thorsrud22
force-pushed
the
fix/bare-except-cli-docs
branch
from
September 13, 2026 18:58
de88353 to
7105ce9
Compare
Contributor
|
@Thorsrud22 are you able to action the CLA? |
Thorsrud22
force-pushed
the
fix/bare-except-cli-docs
branch
from
September 16, 2026 18:26
7105ce9 to
c6b3d0a
Compare
Author
|
Thanks for asking, @cybermaggedon. I'd rather not sign a CLA, so I'm closing this. The changes are small and self-contained, so anyone is welcome to pick them up. Sorry for not noticing the CLA requirement before opening it. |
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.
Refs #783. Takes the slice I claimed on the issue: three of the remaining bare
except:clauses outsidetests/onrelease/v2.9.Summary
trustgraph-cli/trustgraph/cli/set_prompt.py:129: the--schemaparse catchesjson.JSONDecodeErroronly, and chains it (raise ... from e) so the position of the JSON error is kept on theRuntimeError.trustgraph-cli/trustgraph/cli/load_structured_data.py:167: the temp-descriptor cleanup in thefinallyblock catchesOSErroronly (which coversFileNotFoundError).docs/generate-api-docs.py:112: theinspect.signaturefallback catchesTypeErrorandValueError, the two exceptions it documents raising, instead of everything.Behaviour for the normal paths is unchanged; only
KeyboardInterrupt/SystemExit(and unrelated bugs) now propagate instead of being silently swallowed.Tests
tests/unit/test_cli/test_set_prompt_errors.py: invalid--schemaJSON produces the existing "JSON schema must be valid JSON" message and never calls the API; a valid schema is passed through parsed; aKeyboardInterruptraised inside the parse propagates.PYTHONPATH=trustgraph-cli:trustgraph-base python -m pytest tests/unit/test_cli/test_set_prompt_errors.py tests/unit/test_cli/test_load_structured_data.py: 10 passed, 2 skipped (pre-existing skips).python -m py_compileon the three edited files.Not touched:
load_doc_embeds.py/save_doc_embeds.py(claimed by @chiruu12) and the two ontology files, which are still open for someone else.