Skip to content

Diff parsing fails with opaque error when SSH warnings preceed the standard header #574

Closed
@aalong-tr

Description

@aalong-tr

Subject of the issue

I'm experiencing a transient error in a CI environment using the Danger gem. The exception and relevant stack trace:

undefined method `[]' for nil:NilClass
/home/circleci/repo/vendor/bundle/ruby/2.7.0/gems/git-1.10.2/lib/git/diff.rb:148:in `block in process_full_diff'
/home/circleci/repo/vendor/bundle/ruby/2.7.0/gems/git-1.10.2/lib/git/diff.rb:131:in `each'
/home/circleci/repo/vendor/bundle/ruby/2.7.0/gems/git-1.10.2/lib/git/diff.rb:131:in `process_full_diff'
/home/circleci/repo/vendor/bundle/ruby/2.7.0/gems/git-1.10.2/lib/git/diff.rb:110:in `process_full'
/home/circleci/repo/vendor/bundle/ruby/2.7.0/gems/git-1.10.2/lib/git/diff.rb:68:in `each

I have identified the root cause as git diff output that includes an SSH key warning:

Warning: Permanently added the ECDSA host key for IP address '000.00.000.0' to the list of known hosts.
diff --git a/some/file/name b/some/file/name

(IP address obscured)

While SSH warnings are not necessarily the responsibility of this gem, better error handling with explicit explanation of why the git diff output did not match expected formatting would make this style of error significantly easier to identify and fix.

Your environment

  • ruby-git version 1.10.2
  • Ruby version 2.7.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions