Repository navigation
Studio: hide host cache inventory from API keys - #10265
Souravrajvi0 wants to merge 7 commits into
Conversation
/api/hub/cached-models and /cached-gguf list repo ids, sizes, capabilities and absolute cache paths. After unslothai#10076 they take a token but still answered any authenticated caller, including an API key denied the ambient credential. UI sessions keep the full local scan. API keys get an empty listing so they cannot inventory this host. The in-process CLI catalog still walks disk directly and is unchanged.
|
allow_ambient_hf_token |
Use authenticated_with_sk_unsloth_key instead of allow_ambient_hf_token on /api/hub/cached-models and /cached-gguf. Keyless local CLI consumers still enumerate downloaded models; only sk-unsloth API keys get an empty list (not a 403, to avoid leaking that the host has cached repos).
The keyless cached-models/cached-gguf test 401ed because get_request_hf_token still depends on allow_ambient_hf_token/HTTPBearer. Override that dependency and unit-test the sk-unsloth helper itself.
|
Good catch — Change: Empty list vs 403: still an empty list for API keys — a 403 would confirm that the host has cached repos. Tests: inventory hidden from sk-unsloth key; UI session and keyless caller still scan; direct unit test on the new helper. |
Fix import-hoist lint: module-level hoist looked unused to the verifier.
|
Thanks for switching to the sk-unsloth-only helper, the keyless CLI case I raised is covered by the new tests. One thing before I review: an integration using an API key to list downloaded models now silently gets an empty |
Resolve test_hub_token_caller_identity merge and assert legacy /api/models/cached-models stays ungated for sk-unsloth keys.
|
@danielhanchen — yes, the split is intentional.
Merged latest |
|
Thanks for the PR and for the follow-up on the keyless CLI case! Closing this one since it has been superseded by #11026, which landed on main and covers the same two routes ( #11026 took a different approach to the same concern: the inventory still answers every authenticated caller with repo ids, sizes, capabilities and partial state, but for an Item 2 of #10147 is addressed by #11026. Thanks again for working through the caller boundary slices! |
Summary
Part of #10147 (item 2 —
/api/hub/cached-modelsand/api/hub/cached-gguf).These routes enumerate cached repo ids, sizes, capabilities and absolute cache paths. #10076 only changed the token annotation; they still answered any authenticated caller, including an API key denied the ambient token. They never claimed Hub authorization: they are a local filesystem inventory.
This draws the same caller boundary as the other #10147 slices:
allow_ambient_hf_token): full host scan, unchanged{cached: [], scan_confirmed: true}— even if the key sendsX-Unsloth-HF-TokenAn HF token is not a license to inventory this machine. Empty list rather than 403 so existing clients that iterate
cachedkeep working.The in-process CLI catalog (
unsloth_cli/_model_catalog.py) still scans disk directly and is unchanged. Legacy/api/models/cached-modelsis unchanged in this PR (no token, out of the issue's named scope).Test plan
python -m pytest tests/test_hub_token_caller_identity.py -k hub_cache_inventory(4 passed)