backdrop-contrib / mastotoot

Automatically share your Backdrop CMS posts on a Mastodon instance.
https://backdropcms.org/project/mastotoot
GNU General Public License v2.0
1 stars 0 forks source link

Got error code 400. Unprocessable Content: too long message #1

Open robertgarrigos opened 1 year ago

robertgarrigos commented 1 year ago

When setting the "Field for additional text" to body field, it tries to send the whole text top mastodon, instead of just a teaser, which generates an error from it: too many characters.

indigoxela commented 1 year ago

When setting the "Field for additional text" to body field, it tries to send the whole text top mastodon

Can you clarify that, please?

The text limit to send is 500: https://github.com/backdrop-contrib/mastotoot/blob/1.x-1.x/mastotoot.class.inc#L176

How did you manage to send a longer text, then?

indigoxela commented 11 months ago

@robertgarrigos I had a quick idea, what might be causing the length problem. But for that I'd need several infos from the node causing the problem:

robertgarrigos commented 11 months ago

Here it is:

node body:

<p>Desenes de persones han passat pel centre de Sant Feliu entre divendres i diumenge per visitar la Fira de Nadal, la Casa dels desitjos, i han participat en les diverses activitats que s’han organitzat.<br />
Un dels moments més especials, però ha estat aquest divendres amb l’encesa dels llums de Nadal dels carrers del poble, i de l’arbre instal·lat a la Plaça.<br />
Enguany, el nou govern ha apostat per fer diversos canvis pel que fa la decoració nadalenca. D’una banda s’ha prescindit per primer cop de l’arbre natural que habitualment presidia la Plaça Josep Umbert Ventura, que s’ha substituït per un de lluminós. En relació als llums dels carrers, s’han llogat a una empresa externa, amb l’objectiu de renovar-los, arribar a més punts del terme municipal, i reduir la despesa elèctrica que generaven els anteriors.<br />
Nosaltres hem sortit al carrer i hem preguntat a la gent quina opinió tenen del nou arbre i el nou enllumenat.</p>

<p>Escolteu la notícia sencera <a href="https://alacarta.onacodinenca.cat/programs/eix59/onacodinenca_podcast_12059?s=778&amp;ref=wa">aquí.</a><br />
&nbsp;</p>

title: Clone of L'opinió dels codinencs sobre l'arbre de Nadal de la Plaça i el nou enllumenat dels carrers

tags: sant feliu de codines, festes de nadal

libxml version: 2.10.2

indigoxela commented 11 months ago

Hm, I just used the exact same body content, tags, title, and it got published without any problem to my testing instance. toot-success

I do note this odd &#13; (=newline) in the middle (note that I have a different language set on my site than you have), but it didn't break publishing.

Your libxml version is much newer than mine, I have 2.9.14 - these two should behave the same, though.

So, still no way to reproduce.

indigoxela commented 11 months ago

@robertgarrigos in the meantime I've fixes an issue that may or may not be related (not when I was testing, but...).

Can you try with the latest dev?

robertgarrigos commented 11 months ago

Tried latest dev. Same error.... :-(

indigoxela commented 11 months ago

Hm... Do you have the devel module installed? Here's some code to run:

$node = node_load(200);// <- use your NID here!

$text_fields = field_get_items('node', $node, 'body');
$text_field = reset($text_fields);
$stripped = strip_tags($text_field['value']);
$text = text_summary($stripped, NULL, 335);
$text = html_entity_decode($text);

debug($text);

What do you get here as output?

robertgarrigos commented 11 months ago

nothing. blank output

indigoxela commented 11 months ago

nothing. blank output

What? Are you sure, you picked the right nid? In my example I used 200, but your node id is different, for sure.

indigoxela commented 11 months ago

Wait... thinking this over. Maybe error display is completely off on your site. In that case the output still gets logged. What do you find on /admin/reports/dblog re that code?

robertgarrigos commented 11 months ago

This is what I get in the dblog:

User notice:
'El Taula per 5 d\'aquest dimecres ha comptat amb Pol Cabutí de Primàries Codines, Manuela Jimena de Junts per Sant Feliu de Codines, Anna Maria Vilarrasa de Junts per Catalunya i Laia Jordana del PSC.

Podeu recuperar el programa aquí. 

La propera edició del \'Taula per 5\' serà dimecres 8 de novembre a les 20 hores.
'
a eval() (línia 9 de /Users/robert/Sites/ona/modules/devel/devel.module(1184) : eval()'d code).
indigoxela commented 11 months ago

That's a different node, though.

However, the length is fine, the body content got shortened as desired.

How's the content for the node you posted initially? The one with the title "Clone of L'opinió dels codinencs sobre...".

Another question: do all nodes get rejected by your Mastodon instance, or does it only happen for specific nodes. If so, what's the difference? Are you in contact with your Mastoadmin?

robertgarrigos commented 11 months ago

Yes, it is a different node, but this one also triggered the error. All nodes seem to get rejected. I could contact my Mastoadmin, yes.

indigoxela commented 11 months ago

All nodes seem to get rejected.

With all setup variants, or only when you try to add the snippet from "body"?

I could contact my Mastoadmin, yes.

Yes, that might help. The error message just doesn't make any sense to me. Maybe it's a totally different problem and we're just wasting time here. Maybe there's really a problem with the module, that only shows up on specific instances.

Personally, I ran completely out of ideas. But I'd appreciate, if you investigate further and let us know, what the problem is/was. :pray:

robertgarrigos commented 11 months ago

With all setup variants, or only when you try to add the snippet from "body"? No, no, with only setting "Field for additional text" to "body". Otherwise, the node gets posted to mastodon.

I'll contact my mastoadmin.