Skip to content

fix(products): stop saving the uploaded icon file record into a category's icon - #157

Merged
roncodes merged 1 commit into
release/v0.4.26from
fix/product-category-icon
Oct 16, 2026
Merged

roncodes merged 1 commit into
release/v0.4.26from
fix/product-category-icon

Conversation

@roncodes

Copy link
Copy Markdown
Member

Summary

Uploading an icon in the New product category and Edit category modals saved a stringified File record into the category's icon column. The upload callback set icon: uploadedFile next to icon_file_uuid and icon_url. icon is a string attribute on the console's category model. Ember Data's string transform calls String(record), so the save sent "icon": "<model::file:{file uuid}>". core-api mass-fills icon (it is in Category::$fillable), so that string replaced any icon name the category had.

The callbacks now set only icon_file_uuid and icon_url. The catalog category modal does the same since #155.

Related Issue

None. Found while working on #155.

Type of Change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Test
  • Chore

Implementation Notes

Validation

How I confirmed the bug, before the fix:

  • Request payload: I ran the new tests against the unfixed controllers, logging category.serialize() after the upload callback. Both flows sent "icon":"<model::file:file-new>", and both tests failed because category.icon held the File record.

  • DB: in the local application container, inside a transaction I rolled back, I called Category::createRecordFromRequest() with that payload. categories.icon stored <model::file:00000000-0000-0000-0000-000000000001>. After the rollback, 0 rows were left.

  • Tests

  • Lint

  • Build

  • Manual validation

Command output / summary:

$ pnpm exec ember test --filter "/category icon upload|Controller \| products/i"
ok 1 Unit | Controller | products | category icon upload: editing a category links the uploaded icon file without writing it to icon
ok 2 Unit | Controller | products | category icon upload: a new product category links the uploaded icon file without writing it to icon
ok 3-8 Unit | Controller | products/... : it exists
# tests 8, pass 8, fail 0

$ pnpm exec eslint <changed files>      # clean
$ pnpm exec prettier --check <changed files>   # All matched files use Prettier code style!

I didn't run a build or check the change in the console: the local dev server isn't running, and this PR changes no templates. No server code changed, so PHP coverage is unaffected.

Documentation Impact

  • No documentation changes needed
  • Documentation updated in fleetbase/fleetbase.io
  • Documentation needed but not included

API Reference Impact

  • No API reference changes needed
  • Updated fleetbase/postman
  • API reference updates required but not included

API reference notes: none. The API is unchanged. The console just stops sending a bad icon value.

Documentation Notes

None.

Risk

Low. The upload no longer touches icon, so a category's icon name is kept. Product categories that already had an icon uploaded may still hold a <model::file:…> value in categories.icon. My local DB had none. Nothing in the Storefront console renders a product category's icon, so those values are harmless, and this PR doesn't clean them up.

Screenshots / Recordings

None. No UI change.

…ory's icon

Uploading an icon in the new and edit product category modals set the
category's `icon` string attribute to the uploaded File record as well as
`icon_file_uuid` and `icon_url`. The string transform turned the record into
"<model::file:{uuid}>", which the save sent and core-api stored in
`categories.icon`, in place of any icon name the category had. The upload now
sets only `icon_file_uuid` and `icon_url`, as the catalog category modal does.
@roncodes roncodes mentioned this pull request Oct 16, 2026
@roncodes roncodes added the type:bug Bug fix label Oct 16, 2026
@roncodes
roncodes merged commit 3ab3d54 into release/v0.4.26 Oct 16, 2026
@roncodes
roncodes deleted the fix/product-category-icon branch October 16, 2026 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant