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

Percy reports "Invalid snapshot options:" even when there is zero problems #1674

Closed
navrkald opened this issue Jul 22, 2024 · 4 comments · Fixed by #1675
Closed

Percy reports "Invalid snapshot options:" even when there is zero problems #1674

navrkald opened this issue Jul 22, 2024 · 4 comments · Fixed by #1675

Comments

@navrkald
Copy link
Contributor

navrkald commented Jul 22, 2024

The problem

Percy reports "Invalid snapshot options:" even when there is zero problems.

Environment

  • Node version: 20
  • @percy/cli version: 1.29.0
  • Version of Percy SDK you’re using:
  • If needed, a build or snapshot ID:
  • OS version: Mac
  • Type of shell command-line [interface]:

Debug logs

tsc && PERCY_BRANCH=staging npx percy exec -c censored.js -- node censored.js
[percy] Notice: Percy collects CI logs for service improvement, stored for 30 days. Opt-out anytime with export PERCY_CLIENT_ERROR_LOGS=false
[percy] Percy has started!
[percy] Running "node censored.js"
[percy] Invalid snapshot options:
[percy] Snapshot taken: censored
[percy] Finalized build censored
[percy] Build's CLI and CI logs sent successfully. Please share this log ID with Percy team in case of any issues - 35435194_build_35435194_cli_5bdfdd0532339ace71a37854a9c60702339fe9f6
[percy] Command "node censored.js" exited with status: 0

navrkald pushed a commit to navrkald/cli that referenced this issue Jul 22, 2024
navrkald added a commit to navrkald/cli that referenced this issue Jul 22, 2024
@davidrunger
Copy link

davidrunger commented Jul 22, 2024

@navrkald : I believe that you are seeing this because of what I mentioned here: #1656 (comment) . A fix to address the reason that error started emerging is here: #1669 .

That being said, from the PR that you have put together (#1675), I notice that you have noticed something else relevant, which is that [percy] Invalid snapshot options: will be logged even if errors is an empty array, since an empty array is truthy in JavaScript. Prior to the issue that I mentioned above, errors was undefined, which is why nothing was logged, but now errors is an empty array, which is why [percy] Invalid snapshot options: is logged, but then no further details about what is invalid are logged.

Your PR might or might not be something that the Percy maintainers want to accept. In some sense, it's an improvement, since it would avoid this behavior of logging [percy] Invalid snapshot options: but then logging no details about what is invalid. But, in another sense, maybe it's arguably slightly worse, since it might mask underlying problems. In other words, in this case, where adding cookies caused a validation error, should that error have been surfaced to the user? In other words, maybe rather than checking that the errors array has a non-zero length before we log [percy] Invalid snapshot options:, instead the focus should be on making sure that the cookies-related validation errors that triggered this actually make it into the errors array that is checked in the code that you are touching in that PR.

Or maybe the Percy maintainers want to implement both your change (checking that errors is a non-empty array) and what I mentioned (populating these cookies-related errors (or other similar errors in the future) into the errors array).

@navrkald
Copy link
Contributor Author

Hi @davidrunger I am afraid expecting empty errors array as false is clearly bug which should be fixed asap.
If someone doesn't know/believe empty array is truth expression he can run this snipped in browser JS console and will quickly see that my PR is just fixing this super obvious and super simple bug.

if([]) {
  console.log("Empty array is truthfully expression")
}

I am afraid cookie issue, which I just quickly checked, is unrelated issue.

@sarah-gelt
Copy link

This is most definitely a bug - if the errors array is empty then it shouldn't be outputting anything. I just upgraded to 1.29 and thought something must be wrong in our tests even though we have made no other changes related to Percy. I ran one of our smallest projects (only ~25 tests), the output is a mess and it sent me scrambling to the documentation to work out if there's something I missed about the new version that meant our code was now incompatible. Our largest suite has almost 200 tests in it, I can't imagine what that output will look like next time we run it.

Having found this issue report, I now know there is nothing wrong our end and I can warn the rest of our team to ignore all these messages until it's sorted.
image

@sarah-gelt
Copy link

@navrkald your PR got approved 🙌 Hopefully this will get into a release soon.

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 a pull request may close this issue.

3 participants