Icons broken on plone 6 post collective.exportimport migration

I have a plone 4.x site, which I migrated to plone 6 using collective.exportimport. Both sites are buildout based and using the classic UI. I also had a custom add-on which defined pretty much all the content types that were migrated, so before the migration I uplifted the custom add-on to use python3.x and latest plone modules.

After the migration I have noticed all content type icons are not rendering, neither in my /folder_contents directory nor in any of my widgets/ portlets.

The content types were already dexterity based, therefore I assume no changes were needed. This is how their xml is defined within my profiles/default/types directory:

<?xml version="1.0"?>
<object name="mytype" meta_type="Dexterity FTI" i18n:domain="plone"
   xmlns:i18n="http://xml.zope.org/namespaces/i18n">
 <property name="title" i18n:translate="">Group</property>
 <property name="description" i18n:translate="">My type.</property>
 <property name="icon_expr">string:${portal_url}/++resource++my.addon/images/mytype.png</property>

The interesting part is that if I navigate to:

http://localhost/MyPlone/++resource++my.addon/images/mytype.png

I can see the rendered icon correctly. It also works if I navigate from the root rather than from my plone site.

Within the logs, I can see lots of

 [Products.CMFPlone.browser.icons:100][waitress-0] Icon resolver lookup of 'http:' failed, fallback to Plone icon.

So a quick google and came across a bunch of posts:
This PR looked promising, and since it was open I thought i'll try to implement the changes myself. Nothing changed however.

This post seemed like a similar problem.

I tried the suggestion of updating my registry.xml formy custom add-on with the record:

<record name="plone.icon.contenttype/MyNewContentType">
        <field type="plone.registry.field.TextLine">
            <title>MyNewContentType content type icon</title>
        </field>
        <value key="resource">++plone++bootstrap-icons/MyBootstrapIcon.svg</value>
    </record>

And that worked for icons for my portlets/ widgets! However, the when navigating to /folder_contents, not only did I not see them rendered, but I am receiving the following error:

raceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 181, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 390, in publish_module
  Module ZPublisher.WSGIPublisher, line 284, in publish
  Module ZPublisher.mapply, line 98, in mapply
  Module ZPublisher.WSGIPublisher, line 68, in call_object
  Module Products.CMFPlone.browser.icons, line 78, in __call__
TypeError: Resource.__call__() got an unexpected keyword argument 'REQUEST'

Not too sure where to go from here. Looking in ZMI -> portal_types the properties have been pulled appropriately from the xml. The icon expression is defined as:

string:${portal_url}/++resource++my.addon/images/mytype.png

Would appreciate any help

I think (not sure) that the icons in 'toolbar' and in 'folder_contents' are defined two places, something like

 <record name="plone.icon.contenttype/my_type">
  <field type="plone.registry.field.TextLine">
    <title>My Type</title>
  </field>
  <value key="resource">++plone++My.Addon/icons/my_icon.svg</value>
</record>


  <record name="plone.icon.my_type">
    <field type="plone.registry.field.TextLine">
    </field>
    <value>++plone++My.Addon/icons/my_icon_neg.svg</value>
  </record>

Note 1: You can off course use 'existing icons' (so change value to for example: ++plone++bootstrap-icons/calendar-event.svg

Note 2: You dont have to use different icons, but in case the svg defines colors you might have to. Alternatively: open the svg in text editor and remove color (look for style="fill:#123456 or similar)

Note 3: the name of the content type might be confusing, so if for content type is called 'My Type', try (also) 'my_type' (or even 'MyType')

Update: Maybe your content type needs:

 <property name="icon_expr">string:my_type</property>

For this approach (not sure about that either, but looking at some code I think that is how I have it)

Update 2:
I have some code here that might help (?):

Thank you for your response!

I've tried adding the second

 <record name="plone.icon.my_type">
    <field type="plone.registry.field.TextLine">
    </field>
    <value>++plone++My.Addon/icons/my_icon_neg.svg</value>
  </record>

But it seems like it was still pulling the first:

 <record name="plone.icon.contenttype/my_type">

(looking in the console)
Therefore I removed the first, but that just went back to not rendering the icons at all.

All my content types already have the icon_expr as I showed above:

 <property name="icon_expr">string:${portal_url}/++resource++my.addon/images/mytype.png</property>

My guess is that the content types have indexed the icons correctly, but plone.staticresources is having problems looking those icons up for some reason.

I've tried using the same configuration from your add-on, but still getting the same error in Products.CMFPlone when resolving the icon:
http://localhost:8080/MySite/@@iconresolver/contenttype/mytype

Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 181, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 390, in publish_module
  Module ZPublisher.WSGIPublisher, line 284, in publish
  Module ZPublisher.mapply, line 98, in mapply
  Module ZPublisher.WSGIPublisher, line 68, in call_object
  Module Products.CMFPlone.browser.icons, line 78, in __call__
TypeError: Resource.__call__() got an unexpected keyword argument 'REQUEST'

Could you share which version of Zope and Products.CMFPlone you are using?

Update: Tried using default bootstrap icons:

 ++plone++bootstrap-icons/stickies-fill.svg

And that pulls them correctly both in /folder_contents and in my portlets.

This issue has taken way too much time from my hands, and the documentation around both icons Icons — Plone Documentation v6
and Static resources — Plone Documentation v6 is too vague, so decided to add my static icons inside the Products.CMFPlone for now and have them accessed via ++plone++bootstrap-icons

A note on this, I wasn't able to use my .png images even within the bootstrap directory of Products.CMFPlone, the /folder_contents view seems very unreliable in terms of what it can render. Currently I had to convert my png's to svg's.

Also tried to put it within my add-on's configuration

++resource++my.addon/images/myicon.svg

That doesn't work at all. Portlets are unrendable and /folder_contents still broken.

So added the icon in

\plone.staticresources-2.3.0-py3.10.egg\plone\staticresources\static\icons-bootstrap\

That worked, the icons are available within ++plone++bootstrap-icons/myicon.svg which is what I defined for my types in the registry.xml . I'm aware that each time I run a rebuild/ perform an upgrade the icons will be gone and will have to re-add them, but it's all I got going right now, until it becomes more clear how to add icons within plone's bootstrap or how to make icons available from your own add-on

Could you try installing my add-on on a test site and see if the icons work.
I have tried it on 'several (almost all) Plone 6 (Classic) versions.

NOTE: I do not use icon expression as an url, but as a string:

 <property name="icon_expr">string:contenttype/notefication</property>

PS: If you go to /portal_types/manage_main you can check what the other content types are 'using'.