Error in portal_catalog

While reindexing portal_catalog I get the following error:

ERROR plone.app.textfield No transform path found from "application/octet-stream" to "text/x-html-safe".

What does this mean and how to fix this?

I don't know if you've tried this already, but I would do a Google search for 'plone.app.textfield No transform path found'. I'd also look at the code for plone.app.textfield (a link to its github repo is among the Google search results) and see if the code includes hints. You might also look at training.plone.org's Mastering Plone materials to see if they include code and discussion on how to use that textfield.

I should have said that there are no code customizations in my site.

It is all out of the box

it means that some value is set in one or more of your documents that reindexing can't handle. Why I don't know, either a bug in migration or a pinning of an incompatible version of an addon or whatever, it don't matter much the result is that your site needs repair. Unfortunately that's something that pratically needs some (or a lot of) intervention at a debugging level.

I can provide some code for you to assess the damage, save it to a file named (for example) lstbad.py. Put it in your Plone directory (the one where you launch your instance) stop your Plone instance and run the file by typing:

bin/instance run lstbad.py

(I assume that you can start Plone by running bin/instance)

Then the little utility should print a summary of what it has found in your database.
Hopefully the 'bad' documents list that it will print will be short, then you should be able to fix your site by recreating the failed documents. If the list is very long you may need direct assistance.

Code

plone=app.Plone
from zope.component.hooks import setSite
setSite(plone)
from plone import api
with api.env.adopt_user(username='admin'):
     docs = api.content.find(context=plone, portal_type='Document')

lstbad = []
for d in docs:
     doc=d.getObject()
     if doc.text.mimeType:
          if doc.text.mimeType.find('html') == -1:
               lstbad.append((doc.title, doc.text.mimeType))

print('finished, %d good docs, %d bad docs' % (len(docs)-len(lstbad), len(lstbad)))
for x in lstbad:
    print(x)
2 Likes

Is it possible that you have set the MIME type on a rich text field to “application/octet-stream” ?

A bit far fetched, but is it possible that you have added a file, and/or uploaded something for example in /portal_skins/custom which is application/octet-stream ?
A font, maybe ?

You could try:

  1. go to yoursite/manage_main
  2. Search (and click on advanced search)
  3. Enter 'application/octet-stream' in the 'containing' field.

If that does not find anything: search for 'File' or 'ATFile' and check those that look suspicious ('uncommon file types)

Thanks @gp54321, I tried this.

First I get the error

Traceback (most recent call last):
File "/plone/plonefolder/zinstance/parts/instance/bin/interpreter", line 313, in
exec(_val)
File "", line 1, in
File "lstbad.py", line 1, in
plone=app.Plone
AttributeError: Plone

So I think I have to rename Plone with the name of my site, let's say myPlone.
Now I get this:

Traceback (most recent call last):
File "/plone/plonefolder/zinstance/parts/instance/bin/interpreter", line 313, in
exec(_val)
File "", line 1, in
File "lstbad.py", line 11, in
if doc.text.mimeType:
AttributeError: 'NoneType' object has no attribute 'mimeType'

Yes you are right I forgot to warn you about it, glad you figured it out yourself

ugh. I did not expect that naturally :slight_smile: Let's create another file that could be called lstbad2.py then.

plone=app.Plone
from zope.component.hooks import setSite
setSite(plone)
from plone import api
with api.env.adopt_user(username='admin'):
     docs = api.content.find(context=plone, portal_type='Document')

lstbad = []
for d in docs:
    doc=d.getObject()
    if doc.text:
        if doc.text.mimeType:
            if doc.text.mimeType.find('html') == -1:
                lstbad.append((doc.title, doc.text.mimeType))
    else:
        lstbad.append((doc.title, 'no text'))     

print('finished, %d good docs, %d bad docs' % (len(docs)-len(lstbad), len(lstbad)))
for x in lstbad:
    print(x)

I hope that this time I did not miss another feature of your docs.

1 Like

Allright @gp54321 , that looks good :slight_smile: or bad?

Anyway, I now know the bad file with the "octet-stream" thing.

The output looks like this:

(u'damnedfile', 'application/octet-stream')

So this topic is solved, thanks to the glorious @gp54321 , reindexing works now without errors.

But I got some more 'bad docs' according to your code, the output looks like this:

(u'anothermysteryfile', 'no text')

The files with 'no text' are all made with plone.mosaic but as I said there are no errors now while reindexing.

Thanks to @tkimnguyen, @espenmn and of course @gp54321 for their support!

1 Like

if they are special (no standard documents) and everything works there is probably no reason to worry. I don't know anything about mosaic though.

Yeah, glad you figured it out but I too do not understand what you mean by files created by Mosaic.

I meant documents that use a mosaic layout view.