llama-stack/llama_stack/apis
Sébastien Han c029fbcd13
fix: return 4xx for non-existent resources in GET requests (#1635)
# What does this PR do?

- Removed Optional return types for GET methods
- Raised ValueError when requested resource is not found
- Ensures proper 4xx response for missing resources
- Updated the API generator to check for wrong signatures

```
$ uv run --with ".[dev]" ./docs/openapi_generator/run_openapi_generator.sh
Validating API method return types...

API Method Return Type Validation Errors:

Method ScoringFunctions.get_scoring_function returns Optional type
```

Closes: https://github.com/meta-llama/llama-stack/issues/1630

## Test Plan

Run the server then:

```
curl http://127.0.0.1:8321/v1/models/foo     
{"detail":"Invalid value: Model 'foo' not found"}%  
```

Server log:

```
INFO:     127.0.0.1:52307 - "GET /v1/models/foo HTTP/1.1" 400 Bad Request
09:51:42.654 [END] /v1/models/foo [StatusCode.OK] (134.65ms)
 09:51:42.651 [ERROR] Error executing endpoint route='/v1/models/{model_id:path}' method='get'
Traceback (most recent call last):
  File "/Users/leseb/Documents/AI/llama-stack/llama_stack/distribution/server/server.py", line 193, in endpoint
    return await maybe_await(value)
  File "/Users/leseb/Documents/AI/llama-stack/llama_stack/distribution/server/server.py", line 156, in maybe_await
    return await value
  File "/Users/leseb/Documents/AI/llama-stack/llama_stack/providers/utils/telemetry/trace_protocol.py", line 102, in async_wrapper
    result = await method(self, *args, **kwargs)
  File "/Users/leseb/Documents/AI/llama-stack/llama_stack/distribution/routers/routing_tables.py", line 217, in get_model
    raise ValueError(f"Model '{model_id}' not found")
ValueError: Model 'foo' not found
```

Signed-off-by: Sébastien Han <seb@redhat.com>
2025-03-18 14:06:53 -07:00
..
agents chore: deprecate ToolResponseMessage in agent.resume API (#1566) 2025-03-12 12:10:21 -07:00
batch_inference fix: solve ruff B008 warnings (#1444) 2025-03-06 16:48:35 -08:00
benchmarks fix: return 4xx for non-existent resources in GET requests (#1635) 2025-03-18 14:06:53 -07:00
common ci: add mypy for static type checking (#1101) 2025-02-21 13:15:40 -08:00
datasetio feat(api): (1/n) datasets api clean up (#1573) 2025-03-17 16:55:45 -07:00
datasets fix: return 4xx for non-existent resources in GET requests (#1635) 2025-03-18 14:06:53 -07:00
eval fix: return 4xx for non-existent resources in GET requests (#1635) 2025-03-18 14:06:53 -07:00
files fix: return 4xx for non-existent resources in GET requests (#1635) 2025-03-18 14:06:53 -07:00
inference feat(api): remove tool_name from ToolResponseMessage (#1599) 2025-03-12 19:41:48 -07:00
inspect feat: add provider API for listing and inspecting provider info (#1429) 2025-03-13 15:07:21 -07:00
models fix: return 4xx for non-existent resources in GET requests (#1635) 2025-03-18 14:06:53 -07:00
post_training fix: return 4xx for non-existent resources in GET requests (#1635) 2025-03-18 14:06:53 -07:00
providers fix: OpenAPI with provider get (#1627) 2025-03-13 19:56:32 -07:00
safety chore: move all Llama Stack types from llama-models to llama-stack (#1098) 2025-02-14 09:10:59 -08:00
scoring docs: api documentation for agents/eval/scoring/datasets (#1400) 2025-03-05 09:40:24 -08:00
scoring_functions fix: return 4xx for non-existent resources in GET requests (#1635) 2025-03-18 14:06:53 -07:00
shields fix: return 4xx for non-existent resources in GET requests (#1635) 2025-03-18 14:06:53 -07:00
synthetic_data_generation chore: move all Llama Stack types from llama-models to llama-stack (#1098) 2025-02-14 09:10:59 -08:00
telemetry feat: Add new compact MetricInResponse type (#1593) 2025-03-12 15:45:44 -07:00
tools feat: tool outputs metadata (#1155) 2025-02-21 13:15:31 -08:00
vector_dbs fix: return 4xx for non-existent resources in GET requests (#1635) 2025-03-18 14:06:53 -07:00
vector_io chore: move all Llama Stack types from llama-models to llama-stack (#1098) 2025-02-14 09:10:59 -08:00
__init__.py API Updates (#73) 2024-09-17 19:51:35 -07:00
datatypes.py feat: add provider API for listing and inspecting provider info (#1429) 2025-03-13 15:07:21 -07:00
resource.py fix!: update eval-tasks -> benchmarks (#1032) 2025-02-13 16:40:58 -08:00
version.py llama-stack version alpha -> v1 2025-01-15 05:58:09 -08:00