bootcamp icon indicating copy to clipboard operation
bootcamp copied to clipboard

Getting error when a comment has a link

Open Vamoss opened this issue 4 years ago • 3 comments

HTTPError: 400 Client Error: Bad Request for url: https://twitter.com/hashtag/genuary?src=hashtag_click
(10 additional frame(s) were not displayed)
...
  File "django/db/models/query.py", line 433, in create
    obj.save(force_insert=True, using=self.db)
  File "bootcamp/news/models.py", line 52, in save
    data = fetch_metadata(self.content)
  File "bootcamp/helpers.py", line 100, in fetch_metadata
    return get_metadata(urls[0])
  File "bootcamp/helpers.py", line 138, in get_metadata
    response.raise_for_status()
  File "requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)

More information about this issue here: https://github.com/EncontrosDigitais/bootcamp/issues/26

Captura de Tela 2021-02-01 às 09 46 31

Vamoss avatar Feb 01 '21 12:02 Vamoss

This is error is very consistent with twitter links. Can anyone please help?

Vamoss avatar Jul 09 '21 18:07 Vamoss

@Vamoss do you have an example of the original text causing this error? If this is happening with the comments, have you tried changing the comments app version?

sebastian-code avatar Jul 09 '21 21:07 sebastian-code

Hi @sebastian-code, I did some tests here and figure out that it is not only in the comments, it happens also on the news main publishing system.

Here is an example of a Twitter link that breaks the system because it does not have

and HTML tags... https://twitter.com/nervous_jessica/status/1409953583651594247 <p>And here is another example that breaks the system because some sites require the request have a header with user-agent and content-type: https://www.alexandrerangel.art.br/curso-criatividade-audiovisual.html</p> <p>The previous pull request fix both cases.</p>

Vamoss avatar Jul 09 '21 21:07 Vamoss