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

Add some OutputProcessor resilience #148

Merged
merged 4 commits into from
Sep 24, 2012

Conversation

presidentbeef
Copy link
Owner

While this is kind of putting a bandaid on issues like #53, Brakeman should recover properly from errors while formatting code (especially since the error is already being rescued...)

Instead of OutputProcessor#format returning nil when an error occurs or a Sexp is empty, it will now return an empty string. That way when the result of the call is used (e.g. in warnings) it will be safe to expect a string.

Also, tests!
😹

(While no one is probably wondering, OutputProcessor#process_call will likely be removed very soon in another pull request).

If exceptions occured while formatting code,
OutputProcessor#format would return `nil`. Now it should return
a string instead so it can be used safely.
@oreoshake
Copy link
Contributor

How would we get into some of the bad states shown in the tests? Bad input code? Bugs in brakeman code manipulating the AST? Will brakeman eventually output something other than the empty string? Seems like a debug statement would be helpful? Just a little uncomfortable putting something like this in unless this is truly just a short term patch and you have other plans.

@presidentbeef
Copy link
Owner Author

In this case, when I removed the method_missing behavior from Sexp, it turned out there was still some Ruby2Ruby code relying on it (#150). That caused Brakeman to completely bail out when creating the report.

The empty Sexp stuff is weird and I still don't understand where it comes from.

I agree that this will probably hide some issues, which I'm not thrilled about. Even with the debug output (which there is if an exception is raised), no one will notice unless they happen to be running in debug mode.

I would really like this to report an error that bubbles up to the report, but that would mean adding an error to the report while we are generating the report :P

Maybe it should output a regular notification (to stdout)? More likely to be noticed then. Or do you mean instead of an empty string it should say "Processing Error" or something? That makes sense, too.

@oreoshake
Copy link
Contributor

Either or, someone won't be happy either way we go.

  1. Putting "processing error" in the report: clutters the report, much more visible, more eyes likely to see it, could lead to bug reports. Or it could lead to confusion and dismissal of results as buggy.

  2. Printing to stdout: likely to go unnoticed unless the quiet flag is used, won't shock anyone.

I guess I like 1) better, but I'm a power user who understands the "why". Question is, to normal users, would seeing an error in the report impact their experience negatively to a point where they won't use the tool? My guess is no.

@presidentbeef
Copy link
Owner Author

I like (1) better, too. It should be rare enough (hopefully never?) not to turn people off.

instead of just an empty string. This should happen almost never, but
hopefully this will prompt people to report bugs if it does happen
instead of hiding them.
@oreoshake
Copy link
Contributor

Word 👍

@presidentbeef presidentbeef merged commit 7c60a01 into master Sep 24, 2012
Repository owner locked and limited conversation to collaborators Feb 16, 2016
@presidentbeef presidentbeef deleted the output_processor_resilience branch July 22, 2016 19:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants