Skip to content

made optional api calls log to debug instead of error#527

Merged
LinoGiger merged 1 commit intomainfrom
feat/RAPID-7282-remove-unimportant-errors
Apr 13, 2026
Merged

made optional api calls log to debug instead of error#527
LinoGiger merged 1 commit intomainfrom
feat/RAPID-7282-remove-unimportant-errors

Conversation

@LinoGiger
Copy link
Copy Markdown
Collaborator

No description provided.

@claude
Copy link
Copy Markdown

claude bot commented Apr 13, 2026

test

@claude
Copy link
Copy Markdown

claude bot commented Apr 13, 2026


Code Review

Overall this is a clean, DRY refactor. The optional_api_call context manager nicely encapsulates the repeated "swallow-and-log-at-debug" pattern and makes the intent clear at each call site.

Minor issues

1. Missing return type annotation

Per project convention (CLAUDE.md: use from __future__ import annotations), the new context manager should carry a return type. Currently it has none:

@contextmanager
def optional_api_call(description: str):

Should be:

from collections.abc import Generator

@contextmanager
def optional_api_call(description: str) -> Generator[None, None, None]:

This will also satisfy pyright (which CLAUDE.md requires to pass clean).


2. suppress_rapidata_error_logging() is a no-op for _check_version

optional_api_call wraps everything in suppress_rapidata_error_logging(), which only affects errors flowing through RapidataApiClient.response_deserialize. But _check_version uses requests.get directly -- it never touches RapidataApiClient -- so the suppression context does nothing there.

Not a bug (the exception catch still works), but it is a subtle mismatch between what the docstring implies ("RapidataApiClient errors are logged at DEBUG") and what _check_version actually needs (just swallow any network/parse exception). A small docstring clarification would help.


3. Log message wording change (minor)

The original messages were call-site-specific ("Failed to check beta features", "Failed to check for updates"). The new message is generic: "Optional call '%s' failed: %s". Fine for end-users, but worth noting if anyone is grepping for the old strings in tests or monitoring.


What is done well

  • Thread-safe via _thread_local -- correctly restored in finally.
  • Only catches Exception, not BaseException, so KeyboardInterrupt / SystemExit still propagate -- correct design.
  • The @contextmanager mechanics are sound: normal exits, early return, and exceptions inside the with block are all handled correctly.
  • Docstring clearly states the intended use cases.

No blocking issues. Resolve the type annotation (to keep pyright clean) and this is good to merge.

@LinoGiger LinoGiger merged commit 51469d3 into main Apr 13, 2026
2 checks passed
@LinoGiger LinoGiger deleted the feat/RAPID-7282-remove-unimportant-errors branch April 13, 2026 09:19
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.

1 participant