llama-stack-mirror/llama_stack/distribution
Matthew Farrellee b69bafba30
fix(library_client): improve initialization error handling and prevent AttributeError (#2944)
# What does this PR do?

- Initialize route_impls to None in constructor to prevent
AttributeError
- Consolidate initialization checks to single point in request() method
- Improve error message to be more helpful ("Please call initialize()
first")
- Add comprehensive test suite to prevent regressions

The library client now has better error handling when users forget to
call initialize(), showing a clear ValueError instead of confusing
AttributeError. All initialization validation is now centralized in the
request() method, with internal methods (_call_non_streaming,
_call_streaming, _convert_body) relying on this single check for
cleaner, more maintainable code.

closes #2943 

## Test Plan

`./scripts/unit-tests.sh`
2025-07-30 11:58:47 -04:00
..
access_control fix: auth sql store: user is owner policy (#2674) 2025-07-10 14:40:32 -07:00
routers feat(tests): introduce inference record/replay to increase test reliability (#2941) 2025-07-29 12:41:31 -07:00
routing_tables feat(starter)!: simplify starter distro; litellm model registry changes (#2916) 2025-07-25 15:02:04 -07:00
server feat(starter)!: simplify starter distro; litellm model registry changes (#2916) 2025-07-25 15:02:04 -07:00
store fix: store configs (#2593) 2025-07-03 10:07:23 -07:00
ui chore: remove nested imports (#2515) 2025-06-26 08:01:05 +05:30
utils chore: merge --config and --template in server.py (#2716) 2025-07-21 13:19:27 -07:00
__init__.py API Updates (#73) 2024-09-17 19:51:35 -07:00
build.py refactor: install external providers from module (#2637) 2025-07-25 15:41:26 +02:00
build_conda_env.sh refactor: install external providers from module (#2637) 2025-07-25 15:41:26 +02:00
build_container.sh chore: revert #2855 (#2939) 2025-07-28 15:30:25 -07:00
build_venv.sh refactor: install external providers from module (#2637) 2025-07-25 15:41:26 +02:00
client.py chore: make cprint write to stderr (#2250) 2025-05-24 23:39:57 -07:00
common.sh feat(pre-commit): enhance pre-commit hooks with additional checks (#2014) 2025-04-30 11:35:49 -07:00
configure.py fix: separate build and run provider types (#2917) 2025-07-25 12:39:26 -07:00
datatypes.py fix: separate build and run provider types (#2917) 2025-07-25 12:39:26 -07:00
distribution.py refactor: install external providers from module (#2637) 2025-07-25 15:41:26 +02:00
external.py feat: Bring Your Own API (BYOA) (#2228) 2025-07-24 13:41:14 -07:00
inspect.py feat: Bring Your Own API (BYOA) (#2228) 2025-07-24 13:41:14 -07:00
library_client.py fix(library_client): improve initialization error handling and prevent AttributeError (#2944) 2025-07-30 11:58:47 -04:00
providers.py feat: consolidate most distros into "starter" (#2516) 2025-07-04 15:58:03 +02:00
request_headers.py feat(auth): API access control (#2822) 2025-07-24 15:30:48 -07:00
resolver.py refactor: install external providers from module (#2637) 2025-07-25 15:41:26 +02:00
stack.py feat(tests): introduce inference record/replay to increase test reliability (#2941) 2025-07-29 12:41:31 -07:00
start_stack.sh chore: merge --config and --template in server.py (#2716) 2025-07-21 13:19:27 -07:00