chrispanag
(Christos Panagiotakopoulos)
Mars 7, 2021, 9:40
1
Lorsque j’essaie de modifier le premier message de ce sujet , je reçois une erreur HTTP 500. Les journaux d’erreurs signalent cette erreur fatale :
Message (7 copies signalées)
PG::StringDataRightTruncation (ERREUR : la valeur est trop longue pour le type character varying(500)
)
app/models/topic_link.rb:240:in `safe_create_topic_link'
app/models/topic_link.rb:334:in `ensure_entry_for'
app/models/topic_link.rb:128:in `block (2 levels) in extract_from'
app/models/topic_link.rb:126:in `block in extract_from'
app/models/topic_link.rb:124:in `each'
app/models/topic_link.rb:124:in `extract_from'
lib/post_revisor.rb:224:in `revise!'
app/controllers/topics_controller.rb:379:in `update'
app/controllers/application_controller.rb:358:in `block in with_resolved_locale'
app/controllers/application_controller.rb:358:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:68:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:355:in `call'
config/initializers/100-quiet_logger.rb:23:in `call'
config/initializers/100-silence_logger.rb:31:in `call'
lib/middleware/enforce_hostname.rb:23:in `call'
lib/middleware/request_tracker.rb:177:in `call'
Backtrace
rack-mini-profiler (2.3.1) lib/patches/db/pg.rb:113:in `exec'
rack-mini-profiler (2.3.1) lib/patches/db/pg.rb:113:in `async_exec'
mini_sql (1.0.1) lib/mini_sql/postgres/connection.rb:201:in `run'
mini_sql (1.0.1) lib/mini_sql/postgres/connection.rb:56:in `query_single'
app/models/topic_link.rb:240:in `safe_create_topic_link'
app/models/topic_link.rb:334:in `ensure_entry_for'
app/models/topic_link.rb:128:in `block (2 levels) in extract_from'
activerecord (6.0.3.3) lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `block in transaction'
activerecord (6.0.3.3) lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_transaction'
activesupport (6.0.3.3) lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
Env
HTTP HOSTS : rembetiko.gr
2 « J'aime »
sam
(Sam Saffron)
Mars 8, 2021, 4:31
2
On dirait que cela a un lien avec l’URL, qui dépasse 500 caractères.
Nous devrions certainement la tronquer et éventuellement la sauter, sans provoquer d’erreur 500.
Quelle est la longueur maximale de l’URL dans le message ?
4 « J'aime »
chrispanag
(Christos Panagiotakopoulos)
Mars 8, 2021, 9:27
3
Merci @sam ,
la seule URL de l’article provient d’une citation. L’URL est la suivante :
https://rembetiko.gr/t/%CE%BC%CE%B1%CE%BA%CE%AC%CE%BC-%CE%B2%CF%85%CE%B6%CE%B1%CE%BD%CF%84%CE%B9%CE%BD%CE%BF%CE%AF-%CE%B4%CF%81%CF%8C%CE%BC%CE%BF%CE%B9/6034/30
2 « J'aime »
sam
(Sam Saffron)
Mars 8, 2021, 9:33
4
Cela ne fait que 159 caractères… voyons ce qui se passe ici :
Γιάννη, εκτός από τις ευχές μπου γιά Καλό Πάσχα, θέλω να πω πως πίστευα ότι το θέμα έχει λυθεί προ καιρού. Όχι μόνο από τα πρίμα-σεγκόντα και πέρα, αλλά ακόμα και στην Πειραιώτικη κομπανία, αλλά και σ΄ένα σεβαστό μέρος της Σμυρνέϊκης του Πειραιά...
Μακάμ - Βυζαντινοί Δρόμοι - #30 από kwstas_ferris - Παραδοσιακή μουσική - Ρεμπέτικο Φόρουμ
C’est étrange… impossible de reproduire avec cette URL.
Peut-être lié au fait que c’est le premier message ?
2 « J'aime »
chrispanag
(Christos Panagiotakopoulos)
Mars 8, 2021, 9:58
5
Cela est lié au titre du sujet. Lorsque j’ai modifié le titre du sujet pour le rendre plus court, les erreurs ont cessé. Lorsque j’ai essayé de le restaurer à sa longueur d’origine, une erreur 500 est apparue lors de la mise à jour du titre. Après cette erreur 500, j’ai actualisé la page et le titre a été mis à jour.
3 « J'aime »
chrispanag
(Christos Panagiotakopoulos)
Mars 8, 2021, 1:21
6
J’ai investigué un peu plus loin :
Cela se produit lors de la mise à jour du message « lié » (celui qui est cité) pour y inclure un lien vers la citation. Le lien (en raison d’un titre très long) dépasse les 500 caractères, ce qui déclenche ce problème.
Le lien réel sur le message lié n’est jamais mis à jour si le titre est très long.
4 « J'aime »
sam
(Sam Saffron)
Mars 8, 2021, 10:43
7
@Osama , peux-tu ajouter à ta liste d’investigations une troncation plus tolérante dans le cœur, idéalement en la reproduisant dans un cas de test.
Ce n’est certainement pas urgent, quand tu auras un moment.
3 « J'aime »
chrispanag
(Christos Panagiotakopoulos)
Avril 1, 2021, 8:23
8
Désolé de relancer, mais ce bug a-t-il été résolu ? Aujourd’hui, j’ai constaté une deuxième occurrence de ce problème sur notre forum…
Merci pour tout votre travail acharné !
1 « J'aime »
sam
(Sam Saffron)
Avril 6, 2021, 2:52
9
Nous sommes malheureusement un peu occupés. C’est sur la liste de @Osama . Nous espérons pouvoir nous en occuper d’ici les 4 prochaines semaines.
4 « J'aime »
andrei
(Andrei Prigorshnev)
Juin 2, 2021, 11:32
14
@chrispanag le problème est maintenant résolu :
master ← fix/string-data-right-truncation-when-linking-posts
merged 11:27AM - 02 Jun 21 UTC
Users who use encoded slugs on their sites sometimes [run into 500 error](https:… //meta.discourse.org/t/pg-stringdatarighttruncation-error-value-too-long-for-type-character-varying-500/182426) when pasting a link to another topic in a post. The problem happens when generating a backward "reflection" link that would appear in a linked topic:
<img width="400" alt="Screenshot 2021-05-25 at 16 11 53" src="https://user-images.githubusercontent.com/1274517/119496067-29330e80-bd74-11eb-8883-87d71108b4e0.png">
Link URL restricted on the database level to 500 chars in length. At first glance it should work since we have a restriction on topic title length:
<img width="450" alt="Screenshot 2021-05-24 at 17 56 24" src="https://user-images.githubusercontent.com/1274517/119494745-b2494600-bd72-11eb-8bdc-a3e70c62fdf4.png">
But it doesn't work when a site uses encoded slugs, like [here](https://rembetiko.gr/t/%CE%B2%CF%81%CE%AE%CE%BA%CE%B1-%CE%BA%CE%AC%CF%84%CE%B9-%CE%B3%CE%B9%CE%B1-%CE%BC%CE%AD%CE%BD%CE%B1-%CF%84%CE%BF-%CF%81%CE%B5%CE%BC%CF%80%CE%AD%CF%84%CE%B9%CE%BA%CE%BF-%CF%84%CF%81%CE%B1%CE%B3%CE%BF%CF%8D%CE%B4%CE%B9-%CE%B5%CE%AF%CE%BD%CE%B1%CE%B9-%CE%BA%CE%B1%CF%84%CE%AC-%CE%B2%CE%AC%CF%83%CE%B9%CE%BD-%CE%B1%CF%81%CE%BC%CE%BF%CE%BD%CE%B9%CE%BA%CE%BF-%CE%BA%CE%B1%CE%B9-%CE%B4%CE%B9%CE%AC-%CF%84%CE%BF%CF%8D%CF%84%CE%BF-%CF%80%CE%BF%CE%BB%CF%85%CF%86%CF%89%CE%BD%CE%B9%CE%BA%CE%BF/42000) (take a look at the URL). The link to a topic, in this case, can be much longer than 500 characters.
By the way, an error happens only when generating a "reflection" link and doesn't happen with a direct link, we [truncate that link](https://github.com/discourse/discourse/blob/6e2ecf40c7456a1af7f6470d09921f0138fbd4bb/app/models/topic_link.rb#L309). It works because, in this case, the original long link is still present in the post body and can be used for navigation. But we can't do the same for backward "reflection" links (without rewriting their implementation), the whole link must be saved to the database.
The simplest and cleanest solution will be just to remove the restriction on the database level. Abuse is impossible here since we are already protected by the restriction on topic title length. There aren’t performance benefits in using length-constrained columns in Postgres, in fact, length-constrained columns need a few extra CPU cycles to check the length when storing data ([doc](https://www.postgresql.org/docs/9.3/datatype-character.html)).
Comme vous l’avez dit, l’erreur se produisait lors de la génération d’un lien retour depuis le message lié vers le message original, lorsque ce dernier avait un titre long.
3 « J'aime »
chrispanag
(Christos Panagiotakopoulos)
Juin 4, 2021, 1:32
15
Merci beaucoup pour votre correction !
1 « J'aime »
sam
(Sam Saffron)
A fermé ce sujet ()
Juin 5, 2021, 8:00
16
Ce sujet a été automatiquement fermé après 2 jours. De nouvelles réponses ne sont plus autorisées.