Skip to content

Fail crawl with fatal message if custom behavior isn't loaded #799

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

Merged
merged 4 commits into from
Apr 1, 2025

Conversation

tw4l
Copy link
Member

@tw4l tw4l commented Mar 26, 2025

Fixes #797

The crawler will now exit with a fatal log message and exit code 17 if:

  • A Git repository specified with --customBehavior cannot be cloned successfully (new)
  • A custom behavior file at a URL specified with --customBehavior is not fetched successfully (new)
  • No custom behaviors are collected at a local filepath specified with --customBehavior, or if an error is thrown while attempting to collect files from a nonexistent path (new)
  • Any custom behaviors collected fail Browser.checkScript validation (existing behavior)

Tests have also been added accordingly.

@tw4l tw4l requested a review from ikreymer March 26, 2025 19:35
const newBehaviors = await collectLocalPathBehaviors(filePath, depth + 1);
behaviors.push(...newBehaviors);
}
if (!behaviors && depth === 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Hm, does this mean that specifying an empty directory will lead to an error? I think that could be allowed, as long as directory exists?

Copy link
Member Author

@tw4l tw4l Mar 31, 2025

Choose a reason for hiding this comment

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

It will only lead to an error if pointed to a directory with no behaviors in that directory or any of its subdirectories. I think that makes sense? If someone is pointing at a directory or Git repo expecting the therein to get added but no behaviors are found, it's probably an error of some sort.

Copy link
Member Author

Choose a reason for hiding this comment

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

(Pointing out Git repo here because we first clone the git repo and then collect behaviors from the cloned repo via this codepath)

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, just thinking if maybe should allow having a placeholder directory that things will be added to later.. I guess could always add a sample behavior or something like that..

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah if we go that way I'd suggest we do add a sample behavior. Otherwise we might be setting people up for silent errors?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll leave it up to your judgment though

@ikreymer ikreymer merged commit 5fedde6 into main Apr 1, 2025
4 checks passed
@ikreymer ikreymer deleted the issue-797-fail-if-cant-fetch-behavior branch April 1, 2025 00:35
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.

Fail crawl if custom behavior cannot be fetched
2 participants