Skip to content

feat: add safe __repr__ to WatsonxBackend and LiteLLMBackend #1317

Closed

Description

@planetf1

Context

PR #1262 added a __repr__ / __str__ to OpenAIBackend that shows model_id and base_url while masking the API key as ***. During review, @jakelorocco noted that the other backends should be handled too.

Backends to update

Backend Credential exposure risk Notes
WatsonxBackend Yes Stores self._creds = Credentials(url=..., api_key=...) — if Credentials.__repr__ surfaces the key, it leaks into logs/debug output
LiteLLMBackend Low No credential stored on the instance, but has no informative repr today

BedrockBackend is not a class (module-level functions only) — nothing to do there.

What to do

For each backend, add __repr__ / __str__ following the pattern from OpenAIBackend:

  • Show model_id and base_url so the repr is useful for debugging
  • Mask any credential field as '***' (or omit it entirely if not stored on the instance)

Acceptance criteria

  • repr(WatsonxBackend(..., api_key="secret")) does not contain "secret"
  • repr(LiteLLMBackend(...)) returns something more useful than <LiteLLMBackend object at 0x...>
  • Unit tests added for each (following the pattern in test/backends/test_openai_unit.py)

Activity

  1. added
    enhancement
    on Jun 23, 2026
  2. added
    p2
    on Jun 23, 2026
  3. cptnm3 commented on Jun 30, 2026

    @cptnm3
    Contributor

    Hi team, I would like to contribute to fix this issue.

  4. added a commit that references this issue on Jul 7, 2026
    7a4f934
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementp2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions