Skip to content

Ignore unparsable stdout #40

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 1 commit into from
Jun 22, 2016
Merged

Ignore unparsable stdout #40

merged 1 commit into from
Jun 22, 2016

Conversation

pbrisbin
Copy link
Contributor

Looking at the full stack from this bugsnag[1]

NoMethodError: undefined method `-' for nil:NilClass

Originating from:

begin_index = lines.fetch("begin") - 1

This tells me an engine output { begin: null }. The events for this
errored build show it was a fixme engine that did this.

It looks like grep outputting to stdout something that doesn't match the
expected format could easily cause this:

var parts = line.split(':');
// => ["the whole line"]

var lineNumber = parseInt(parts[1], 10);
// => NaN

var issue = {
  'location': {
    'begin': lineNumber,
    // => 'begin': NaN
}

this.output.write(JSON.stringify(issue) //...
// {"begin":null}

An assertion that we have all the values we expected before printing the
issue should prevent downstream errors.

NOTE: CLI validations would catch this, since they run before the output
filter. In builder's case, the output filter runs before validations so
invalid issues can get in there and cause these errors. Addressing this
is a larger track of work, so fixing misbehaving engines is valuable in
the meantime.

1: https://bugsnag.com/code-climate/builder/errors/57546cf2be3f29e6a63111c8?event_id=5769f0b4076813321236b4e1

/cc @codeclimate/review @mrb

Looking at the full stack from this bugsnag[1]

    NoMethodError: undefined method `-' for nil:NilClass

Originating from:

    begin_index = lines.fetch("begin") - 1

This tells me an engine output { begin: null }. The events for this
errored build show it was a fixme engine that did this.

It looks like grep outputting to stdout something that doesn't match the
expected format could easily cause this:

    var parts = line.split(':');
    // => ["the whole line"]

    var lineNumber = parseInt(parts[1], 10);
    // => NaN

    var issue = {
      'location': {
        'begin': lineNumber,
        // => 'begin': NaN
    }

    this.output.write(JSON.stringify(issue) //...
    // {"begin":null}

An assertion that we have all the values we expected before printing the
issue should prevent downstream errors.

NOTE: CLI validations would catch this, since they run before the output
filter. In builder's case, the output filter runs before validations so
invalid issues can get in there and cause these errors. Addressing this
is a larger track of work, so fixing misbehaving engines is valuable in
the meantime.

1: https://bugsnag.com/code-climate/builder/errors/57546cf2be3f29e6a63111c8?event_id=5769f0b4076813321236b4e1
@mrb
Copy link
Contributor

mrb commented Jun 22, 2016

LGTM

@pbrisbin
Copy link
Contributor Author

FYI: tested locally by putting a misbehaving grep in the image that output both valid and invalid lines.

@pbrisbin pbrisbin merged commit 493aff8 into master Jun 22, 2016
@pbrisbin pbrisbin deleted the pb-fix branch June 22, 2016 13:53
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.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy