Skip to content

feat(DEBT-67): add opt-in single-line error display - #2055

Draft
RuellePaul wants to merge 2 commits into
mainfrom
feature/debt-67-more-conciseclean-errors-on-sdk
Draft

feat(DEBT-67): add opt-in single-line error display#2055
RuellePaul wants to merge 2 commits into
mainfrom
feature/debt-67-more-conciseclean-errors-on-sdk

Conversation

@RuellePaul

Copy link
Copy Markdown
Contributor

What

Opt-in simplified error display: SDK errors become a single concise line instead of a full Python traceback + raw GraphQL payload.

Enable it with the KILI_SDK_SIMPLIFY_ERROR_LOGS environment variable (true/1/yes), or with "simplify_error_logs": true in kili-sdk-config.json. Default behavior is unchanged when the flag is not set.

After (flag enabled)

$ python scripts/check_project_status.py
🔍 Vérification du projet cme2rmsjdg0k4an0w4j0iggq3
Project with id cme2rmsjdg0k4an0w4j0iggq3 not found

$ python scripts/add_or_set_metadata.py   # invalid API key
UserWarning: Client domain api is still a work in progress. Method names and return type will evolve.
Invalid API key `**gerg`

How

  • New kili/core/simplified_errors.py:
    • flag resolution (env var takes precedence over the config file)
    • simplify_graphql_error_message() strips [errorCode] prefixes, the "This can be due to:" boilerplate and backend stack-trace lines
    • sys.excepthook renders uncaught kili.* exceptions as a single line — non-Kili exceptions keep their full traceback
    • IPython/Jupyter custom exception handler for notebooks
    • SDK warnings formatted on a single line
  • GraphQLError / AuthenticationFailed build short messages when the flag is enabled (e.g. Invalid API key `**gerg` ); also fixes an unbalanced quote in the batched-error message
  • Hooks are installed at kili import time (env var) and at client init (config file), including the domain client before its early warning
  • Docs: new section in docs/configuration.md, env var reference table, kili-sdk-config.example.json

Tests

  • 27 new unit tests in tests/unit/core/test_simplified_errors.py; full unit suite green; ruff / pylint 10.00 / pyright clean
  • Verified end-to-end against a local backend: invalid API key and unknown project scenarios produce the expected single-line output; legacy output is byte-identical without the flag

DEBT-67 — companion of the label-backend-v2 MR Draft: fix(DEBT-67): remove stack traces from client-facing GraphQL error messages (kili-technology/kili!14274).

When KILI_SDK_SIMPLIFY_ERROR_LOGS=true (or "simplify_error_logs": true in
kili-sdk-config.json), SDK errors are displayed as a single concise line
instead of a full traceback:
- GraphQL errors keep only the actual cause: error codes, boilerplate and
  backend stack traces are stripped
- authentication failures become e.g. "Invalid API key `**gerg`"
- SDK warnings are displayed on one line
- works in plain scripts (sys.excepthook) and IPython/Jupyter (custom exc)

Default behavior is unchanged when the flag is not set.
…ly warning

The domain client emits its work-in-progress warning before building the
legacy client, i.e. before the configuration file had a chance to enable
the simplified display. Enable it from the configuration at the very start
of the domain client init.
@RuellePaul RuellePaul self-assigned this Jul 22, 2026
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.

2 participants