feat(assets) Add asset file_path and display_name response fields
What this does
Adds 2 new optional fields to the asset system's Asset (and AssetCreated) schema:
file_path: The asset's path on disk (if it has one). Includes themodels/{checkpoints,vae,...}/or{input,output}/prefix.display_name: The asset's human-readable display name. Conventionally a the path within prefix, and what is displayed in the loading widget.
Motivation
In asset mode, the asset response's name field is overloaded. Depending on the asset's origin, the same field carries:
- The ID for consumers
- The rendered display label
- (Sometimes) The file path they resolve to
In asset-mode, the frontend has ~10 widget and upload sites that read name or fall back to asset_hash to extract whichever role they need, with per-backend branching where the heuristics differ.
file_path exposes the full namespace-relative locator (models/checkpoints/flux/model.safetensors) as a dedicated field. display_name exposes the within-bucket path (flux/model.safetensors). The frontend can read what it needs without inferring from value shape or branching on backend.
Changes
- Add
file_pathanddisplay_nameto theAssetoutput schema, inherited byAssetCreated. - Populate both fields in the shared asset response builder used by list, detail, upload/create, create-from-hash, and update responses.
- Add path helpers that convert stored absolute reference paths into logical asset paths:
- media assets:
{input,output,temp}/... - model assets:
models/<bucket>/...
- media assets:
- Keep unknown or non-file-backed references nullable/omitted, matching existing
exclude_noneresponse behavior. - Document the new fields in OpenAPI.
- Add focused tests for path computation, upload/list/detail response fields, and hash-only fast-path compatibility.
Verification
uv run --with-requirements requirements.txt --with-requirements tests-unit/requirements.txt pytest -q tests-unit/assets_test/services/test_path_utils.py tests-unit/assets_test/test_uploads.py::test_upload_response_includes_file_path_and_display_name tests-unit/assets_test/test_uploads.py::test_upload_fastpath_from_existing_hash_no_file tests-unit/assets_test/test_crud.py::test_metadata_filename_is_set_for_seed_asset_without_hashuv run --with ruff ruff check app/assets/api/routes.py app/assets/api/schemas_out.py app/assets/services/path_utils.py tests-unit/assets_test/services/test_path_utils.py tests-unit/assets_test/test_uploads.py tests-unit/assets_test/test_crud.py
[!NOTE]
Reviews paused
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
- [ ] âļī¸ Resume reviews
- [ ] đ Trigger review
No actionable comments were generated in the recent review. đ
âšī¸ Recent review info
âī¸ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2cb9ed9c-7dbf-4d72-aa9d-258dc2cb492e
đĨ Commits
Reviewing files that changed from the base of the PR and between 73ba8c6cbd8d11d6a0e22de39773540fba9f0442 and c533a881497d21bc062c84174fbf5cdd71382768.
đ Files selected for processing (6)
app/assets/api/routes.pyapp/assets/api/schemas_out.pyapp/assets/services/path_utils.pyopenapi.yamltests-unit/assets_test/services/test_path_utils.pytests-unit/assets_test/test_uploads.py
đ§ Files skipped from review as they are similar to previous changes (6)
- app/assets/api/schemas_out.py
- openapi.yaml
- app/assets/api/routes.py
- tests-unit/assets_test/services/test_path_utils.py
- tests-unit/assets_test/test_uploads.py
- app/assets/services/path_utils.py
đ Walkthrough
Walkthrough
Adds AssetRoot typing and new path utilities (compute_asset_response_paths, compute_file_path, compute_display_name, get_asset_root_folder_name_and_filepath). Routes now import and use compute_asset_response_paths to populate Asset responses' file_path and display_name (or set them to None). Upload validation for "models" tags now uses is_comfy_model_folder_name. Asset schema and OpenAPI mark name deprecated and add nullable file_path and display_name. Unit and upload tests were added/updated to cover the new behavior.
đĨ Pre-merge checks | â 4 | â 1
â Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | â ī¸ Warning | Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
â Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | â Passed | The title clearly and specifically describes the main change: adding two new response fields (file_path and display_name) to the asset schema. |
| Description check | â Passed | The description is comprehensive and directly related to the changeset, explaining motivation, implementation details, and examples of the new fields. |
| Linked Issues check | â Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | â Passed | Check skipped because no linked issues were found for this pull request. |
âī¸ Tip: You can configure your own custom pre-merge checks in the settings.
⨠Finishing Touches
âī¸ Resolve merge conflicts
- [ ] Resolve merge conflict in branch
synap5e/feat/assets_add_file_path-BE-932
Comment @coderabbitai help to get the list of available commands and usage tips.
Heads up on the x-runtime: [cloud, local] tags here â the established convention in this file is that absence of x-runtime means both runtimes populate the field (i.e. it's the default). All 177 existing x-runtime usages in this file are [cloud] only â they mark cloud-only divergence from the default-both behavior. [cloud, local] is redundant with no tag and introduces a second pattern.
Two cleaner options:
- Drop the
x-runtime: [cloud, local]tags entirely â absence carries the same meaning, and the existing 177[cloud]usages stay self-consistent. This is what the convention currently calls for. - Keep them and file a separate convention-change discussion if there's a reason explicit-over-implicit is preferable here â but that's a wider change that should be applied uniformly, not selectively.
(1) is the smaller change and avoids introducing dual conventions in the same file.