llama-stack-mirror/llama_stack
Akram Ben Aissi 31f85076ad feat: enhance AccessDeniedError with detailed context and improve exception handling
• Enhanced AccessDeniedError class to include user, action, and resource context
  - Added constructor parameters for action, resource, and user
  - Generate detailed error messages showing user principal, attributes, and attempted resource
  - Backward compatible with existing usage (falls back to generic message)

• Updated exception handling in server.py
  - Import AccessDeniedError from access_control module
  - Return proper 403 status codes with detailed error messages
  - Separate handling for PermissionError (generic) vs AccessDeniedError (detailed)

• Enhanced error context at raise sites
  - Updated routing_tables/common.py to pass action, resource, and user context
  - Updated agents persistence to include context in access denied errors
  - Provides better debugging information for access control issues

• Added comprehensive unit tests
  - Created tests/unit/server/test_server.py with 13 test cases
  - Covers AccessDeniedError with and without context
  - Tests all exception types (ValidationError, BadRequestError, AuthenticationRequiredError, etc.)
  - Validates proper HTTP status codes and error message formats

Resolves access control error visibility issues where 500 errors were returned
instead of proper 403 responses with actionable error messages.

Signed-off-by: Akram Ben Aissi <<akram.benaissi@gmail.com>>
2025-07-03 15:36:55 +02:00
..
apis docs: Minor spelling fix (#2592) 2025-07-02 20:26:51 -04:00
cli fix: stack build (#2485) 2025-06-20 15:15:43 -07:00
distribution feat: enhance AccessDeniedError with detailed context and improve exception handling 2025-07-03 15:36:55 +02:00
models fix: finish conversion to StrEnum (#2514) 2025-06-26 08:01:26 +05:30
providers feat: enhance AccessDeniedError with detailed context and improve exception handling 2025-07-03 15:36:55 +02:00
strong_typing chore: enable pyupgrade fixes (#1806) 2025-05-01 14:23:50 -07:00
templates fix: allow default empty vars for conditionals (#2570) 2025-07-01 14:42:05 +02:00
ui build: Bump version to 0.2.13 2025-06-27 23:56:14 +00:00
__init__.py export LibraryClient 2024-12-13 12:08:00 -08:00
env.py refactor(test): move tools, evals, datasetio, scoring and post training tests (#1401) 2025-03-04 14:53:47 -08:00
log.py chore: remove nested imports (#2515) 2025-06-26 08:01:05 +05:30
schema_utils.py chore: enable pyupgrade fixes (#1806) 2025-05-01 14:23:50 -07:00