{"record":{"id":"fb9b36f5f8162d26","repo":"puppetlabs/puppet","slug":"failed-to-diff-files","errorCode":null,"errorMessage":"Failed to diff files","messagePattern":"Failed to diff files","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/file_bucket/dipper.rb","lineNumber":101,"sourceCode":"        end\n      else\n        raise Puppet::Error, _(\"Please provide a file or checksum to diff with\")\n      end\n    elsif file_a\n      if checksum_b\n        tmp_file = ::Tempfile.new('diff')\n        begin\n          restore(tmp_file.path, checksum_b)\n          file_diff = Puppet::Util::Diff.diff(file_a, tmp_file.path)\n        ensure\n          tmp_file.close\n          tmp_file.unlink\n        end\n      elsif file_b\n        file_diff = Puppet::Util::Diff.diff(file_a, file_b)\n      end\n    end\n    raise Puppet::Error, _(\"Failed to diff files\") unless file_diff\n\n    file_diff.to_s\n  end\n\n  # Retrieves a file by sum.\n  def getfile(sum)\n    get_bucket_file(sum).to_s\n  end\n\n  # Retrieves a FileBucket::File by sum.\n  def get_bucket_file(sum)\n    source_path = \"#{@rest_path}#{@checksum_type}/#{sum}\"\n    file_bucket_file = Puppet::FileBucket::File.indirection.find(source_path, :bucket_path => @local_path)\n\n    raise Puppet::Error, _(\"File not found\") unless file_bucket_file\n\n    file_bucket_file\n  end","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/file_bucket/dipper.rb#L83-L119","documentation":"At the end of Dipper#diff, a guard raises Puppet::Error 'Failed to diff files' unless a file_diff result was produced. The usual path is passing neither checksum_a nor file_a, so no comparison branch executed and file_diff stayed nil; the argument-order mistakes of the four-parameter signature are the practical cause.","triggerScenarios":"dipper.diff(nil, sum_b, nil, nil) or an all-nil call; supplying only the b-side operands; permuting the four positional arguments (checksum_a, checksum_b, file_a, file_b) when calling from Ruby.","commonSituations":"Hand-written wrappers around Dipper#diff that misorder or omit the first-side arguments.","solutions":["Supply the first side — checksum_a or file_a — e.g. Dipper#diff(sum_a, sum_b, nil, nil)","Review the signature: diff(checksum_a, checksum_b, file_a, file_b) and check `puppet filebucket help diff`","Fail fast before calling: raise unless checksum_a || file_a"],"exampleFix":"# before\ndipper.diff(nil, nil, '/tmp/a', '/tmp/b') # wait -- this works; the broken form is:\ndipper.diff(nil, sum_b, nil, nil)\n# after\ndipper.diff(nil, nil, '/tmp/a', '/tmp/b') # file_a + file_b","handlingStrategy":"validation","validationCode":"raise ArgumentError, 'diff needs checksum_a or file_a' if checksum_a.nil? && file_a.nil?\nfile_diff = dipper.diff(checksum_a, checksum_b, file_a, file_b)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keyword-argument wrap Dipper#diff in your codebase to avoid the four positional parameters","Assert at least one a-side operand before calling"],"tags":["puppet","filebucket","diff","argument-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}