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

Suggestion: Only warn about missing test suite for API token once #50

Open
mokagio opened this issue Mar 2, 2023 · 5 comments
Open
Labels
enhancement New feature or request

Comments

@mokagio
Copy link
Contributor

mokagio commented Mar 2, 2023

💬 Context

I haven't been able to track why, but one of our projects logs "[BuildkiteTestCollector] error: Failed to upload result, got error: A test suite could not be found with the supplied API token" 678 times when the tests run.

Screenshot 2023-03-02 at 2 35 35 pm

This happens only in that project, as far as I've seen, so I'd say there's something somewhere in how the tests run there that results in several upload attempts.

Still, it might be possible to mitigate this at the library level by only logging the error once, or once per API key used.

📝 Notes

N.A.

👩‍🔧 Technical Design Notes

A refinement might be introducing different logging levels for the library. If logging is verbose, it could log on every failed upload, otherwise only on the first.

🤝 Related

N.A.

@mokagio mokagio added the enhancement New feature or request label Mar 2, 2023
@iampatbrown
Copy link
Collaborator

This happens only in that project, as far as I've seen, so I'd say there's something somewhere in how the tests run there that results in several upload attempts.

@mokagio Do any of the results actually get sent? That error looks like it would be if an incorrect api key was used which would mean the result wouldn't be able to upload unless the tests were run again with a different api key.

Still, it might be possible to mitigate this at the library level by only logging the error once, or once per API key used.

At a library level this will most likely be fixed by #44. That will upload results in batches of 5000 which should mean you'd only see this error once if you sent 678 results.

@mokagio
Copy link
Contributor Author

mokagio commented Mar 21, 2023

👋 @iampatbrown

@mokagio Do any of the results actually get sent? That error looks like it would be if an incorrect api key was used which would mean the result wouldn't be able to upload unless the tests were run again with a different api key.

No results are sent. I get those errors only locally, on my machine, where there's no API key set. In CI everything works as expected.

At a library level this will most likely be fixed by #44.

🎉 – Fair enough. The chance for multiple logs is still there, but with a batch size of 5k, even the most hardcore codebases should get but a few logs locally.

Still, I'm not sure why my other projects print that warning only once when running the tests locally 🤔

@iampatbrown
Copy link
Collaborator

Still, I'm not sure why my other projects print that warning only once when running the tests locally

@mokagio Are they the same error? The error above will occur when an API Key is found but is not valid. Which can only be determined after attempting an upload. If there is no api key or it is empty you will only get one error saying it won't try to upload. Is it possible that project has the API Key set to something? Can it be cleared?

The chance for multiple logs is still there

Yeah true. We could add some logic that essentially stops the uploader after receiving an error like that. It probably just adds a little but if complexity that we'd need to keep in sync with the backend. i.e Ensure the error doesn't change.

@mokagio
Copy link
Contributor Author

mokagio commented Mar 22, 2023

@iampatbrown

Are they the same error?

🤦‍♂️ of course they're not! Thank you for making me realize that.

For some reason I have yet to uncover, the project that floods the log has the token as "" while the other ones correctly set it to nil.

image

image

It's odd, because the setup is the same in both projects. Or rather, should be the same. Evidently, there's something different. It's just a matter of finding it.

The investigation continues... 🕵️‍♂️

@iampatbrown
Copy link
Collaborator

For some reason I have yet to uncover, the project that floods the log has the token as "" while the other ones correctly set it to nil.
@mokagio Right now the main branch will ignore empty strings as well. A new release should be cut soon which should fix the issue for you.

You could potentially point you main and confirm if you'd like

if let apiToken = environment.analyticsToken, apiToken != "" {

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

No branches or pull requests

2 participants