fix: fallback to asset metadata/name when filename missing#8302
Conversation
Amp-Thread-ID: https://ampcode.com/threads/T-019bddf9-ea49-716f-a834-cd8e66b46dcc Co-authored-by: Amp <amp@ampcode.com>
🎨 Storybook Build Status✅ Build completed successfully! ⏰ Completed at: 01/25/2026, 12:23:36 AM UTC 🔗 Links🎉 Your Storybook is ready for review! |
📝 WalkthroughWalkthroughThe filename resolution in Changes
Suggested reviewers
✨ Finishing touches
Comment |
🎭 Playwright Tests:
|
Bundle Size ReportSummary
Category Glance Per-category breakdownApp Entry Points — 22.8 kB (baseline 22.8 kB) • ⚪ 0 BMain entry bundles and manifests
Status: 1 added / 1 removed Graph Workspace — 957 kB (baseline 957 kB) • 🟢 -234 BGraph editor runtime, canvas, workflow orchestration
Status: 1 added / 1 removed Views & Navigation — 80.7 kB (baseline 80.7 kB) • ⚪ 0 BTop-level views, pages, and routed surfaces
Status: 9 added / 9 removed Panels & Settings — 462 kB (baseline 462 kB) • 🟢 -8 BConfiguration panels, inspectors, and settings screens
Status: 12 added / 12 removed User & Accounts — 3.94 kB (baseline 3.94 kB) • ⚪ 0 BAuthentication, profile, and account management bundles
Status: 3 added / 3 removed Editors & Dialogs — 2.83 kB (baseline 2.83 kB) • ⚪ 0 BModals, dialogs, drawers, and in-app editors
Status: 2 added / 2 removed UI Components — 33.7 kB (baseline 33.7 kB) • ⚪ 0 BReusable component library chunks
Status: 5 added / 5 removed Data & Services — 3.18 MB (baseline 3.18 MB) • 🔴 +1 BStores, services, APIs, and repositories
Status: 8 added / 8 removed Utilities & Hooks — 25.2 kB (baseline 25.2 kB) • ⚪ 0 BHelpers, composables, and utility bundles
Status: 7 added / 7 removed Vendor & Third-Party — 10.7 MB (baseline 10.7 MB) • ⚪ 0 BExternal libraries and shared vendor chunks
Other — 6.43 MB (baseline 6.43 MB) • 🟢 -192 BBundles that do not match a named category
Status: 34 added / 34 removed |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/platform/assets/utils/createModelNodeFromAsset.ts (1)
85-96: Make filename error text reflect the fallback chain (Line 88).With the new fallback logic, the error/log still claims
user_metadata.filenameis invalid even when the value comes frommetadata.filenameorname. This is misleading and reduces debuggability. Consider a neutral message that reflects the resolved filename source.💡 Suggested adjustment
- console.error( - `Asset ${validAsset.id} has invalid user_metadata.filename (expected non-empty string, got ${typeof filename})` - ) + console.error( + `Asset ${validAsset.id} has invalid filename (expected non-empty string, got ${typeof filename})` + ) return { success: false, error: { code: 'INVALID_ASSET', - message: `Invalid filename (expected non-empty string, got ${typeof filename})`, + message: `Invalid filename (expected non-empty string, got ${typeof filename})`, assetId: validAsset.id } }
| const filename = userMetadata.filename | ||
| const filename = | ||
| userMetadata.filename || validAsset.metadata?.filename || validAsset.name |
There was a problem hiding this comment.
I'm not sure if userMetadata is required in lines above. To be safe can we do
const userMetadata = validAsset.user_metadata ?? {}
There was a problem hiding this comment.
not sure what else assume we will have user_metadata. That is only populated on the backend now after the user manually edits the model asset
Amp-Thread-ID: https://ampcode.com/threads/T-019bddf9-ea49-716f-a834-cd8e66b46dcc Co-authored-by: Amp <amp@ampcode.com>
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/platform/assets/utils/createModelNodeFromAsset.ts (1)
72-79: Update error log to reflect fallback sources.The log message still references
user_metadata.filename, but the value may now come frommetadata.filenameorname. This can mislead debugging.♻️ Proposed fix
- console.error( - `Asset ${validAsset.id} has invalid user_metadata.filename (expected non-empty string, got ${typeof filename})` - ) + console.error( + `Asset ${validAsset.id} has invalid filename (expected non-empty string, got ${typeof filename})` + )
## Summary Fix model node creation failing when `user_metadata.filename` is missing by falling back to `asset.metadata.filename` or `asset.name`. ## Changes - Add fallback chain for filename: `userMetadata.filename || validAsset.metadata?.filename || validAsset.name` ## Testing Manual testing with assets that have filename in different metadata locations. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8302-fix-fallback-to-asset-metadata-name-when-filename-missing-2f36d73d365081478299e2f2c1abde81) by [Unito](https://www.unito.io) --------- Co-authored-by: Amp <amp@ampcode.com>
Summary
Fix model node creation failing when
user_metadata.filenameis missing by falling back toasset.metadata.filenameorasset.name.Changes
userMetadata.filename || validAsset.metadata?.filename || validAsset.nameTesting
Manual testing with assets that have filename in different metadata locations.
┆Issue is synchronized with this Notion page by Unito