Skip to content

fix: avoid errors and add default empty string#202

Merged
sarod merged 12 commits intomainfrom
fix/110-instagram-capture-fails-if-no-description
Apr 7, 2026
Merged

fix: avoid errors and add default empty string#202
sarod merged 12 commits intomainfrom
fix/110-instagram-capture-fails-if-no-description

Conversation

@raphaelSeguin
Copy link
Copy Markdown
Collaborator

@raphaelSeguin raphaelSeguin commented Mar 19, 2026

Fixes #110
in case the comment is empty, defaults with empty string. In some cases, the comments container is not the third but the second div.

@raphaelSeguin raphaelSeguin requested review from kerrerain and sarod and removed request for sarod March 19, 2026 19:24
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 19, 2026

@raphaelSeguin
Copy link
Copy Markdown
Collaborator Author

Testé sur ces deux cas qui ne fonctionnaient pas :
https://www.instagram.com/p/DWD5jrEoGa8/
https://www.instagram.com/p/DV5uq78jJqa/

in case the comment is empty, defaults with empty string. In some cases,
the comments container is not the third but the second div.
@raphaelSeguin raphaelSeguin force-pushed the fix/110-instagram-capture-fails-if-no-description branch from 8f378f2 to 5d4f619 Compare March 19, 2026 19:27
HTMLElement,
return tryOrElse(
() =>
this.scrapingSupport.selectOrThrow(
Copy link
Copy Markdown
Collaborator

@sarod sarod Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je pense qu'utiliser this.scrapingSupport.select plutôt que faire un catch sur selectOrThrow serait plus simple ici.

Par exemple le code suivant serait équivalent

return this.scrapingSupport.select(element, ":scope span>div>span", HTMLElement)?.textContent || "";

HTMLElement,
const commentsContainer = tryOrElse(
() =>
this.scrapingSupport.selectOrThrow(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ici aussi select serait peut-être plus adapté.


for (const comment of commentElements) {
comments.push(this.scrapCommentThread(comment));
try {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dans quel cas ce try -catch est-il utile?
Est-ce pour ajouter plus de résilience de manière générale ou pour gérer un cas en particulier?

baseElement,
":scope>div>div:nth-of-type(2)>span",
HTMLElement,
const postContent = tryOrElse(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

je privilegierais là aussi select a la place de selctOrThrow + tryOrElse

raphaelSeguin and others added 9 commits March 30, 2026 22:42
in case the comment is empty, defaults with empty string. In some cases,
the comments container is not the third but the second div.
…ithub.com:dataforgoodfr/14_BalanceTesHaters into fix/110-instagram-capture-fails-if-no-description
in case the comment is empty, defaults with empty string. In some cases,
the comments container is not the third but the second div.
in case the comment is empty, defaults with empty string. In some cases,
the comments container is not the third but the second div.
…ithub.com:dataforgoodfr/14_BalanceTesHaters into fix/110-instagram-capture-fails-if-no-description
@njouanin njouanin requested a review from sarod April 4, 2026 20:30
@sarod sarod changed the base branch from main to 19-interface-extension-chrome April 5, 2026 16:08
@sarod sarod changed the base branch from 19-interface-extension-chrome to main April 5, 2026 16:08
Comment thread browser-extension/src/lib/utils.ts Outdated
@sarod sarod merged commit b66470f into main Apr 7, 2026
4 checks passed
@sarod sarod deleted the fix/110-instagram-capture-fails-if-no-description branch April 7, 2026 20:27
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

Successfully merging this pull request may close these issues.

Instagram: La capture échoue si un commentaire n'a pas de texte

3 participants