Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting error when a comment has a link #241

Open
Vamoss opened this issue Feb 1, 2021 · 3 comments
Open

Getting error when a comment has a link #241

Vamoss opened this issue Feb 1, 2021 · 3 comments

Comments

@Vamoss
Copy link

Vamoss commented Feb 1, 2021

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:
EncontrosDigitais#26

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

@Vamoss
Copy link
Author

Vamoss commented Jul 9, 2021

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

@sebastian-code
Copy link
Collaborator

@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?

Vamoss added a commit to Vamoss/bootcamp that referenced this issue Jul 9, 2021
@Vamoss
Copy link
Author

Vamoss commented Jul 9, 2021

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 <title> HTML tags...
https://twitter.com/nervous_jessica/status/1409953583651594247

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

The previous pull request fix both cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants