{"record":{"id":"2380d419f913d2af","repo":"puppetlabs/puppet","slug":"please-provide-a-file-or-checksum-to-diff-with","errorCode":null,"errorMessage":"Please provide a file or checksum to diff with","messagePattern":"Please provide a file or checksum to diff with","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/file_bucket/dipper.rb","lineNumber":85,"sourceCode":"    if checksum_a\n      source_path = \"#{@rest_path}#{@checksum_type}/#{checksum_a}\"\n      if checksum_b\n        file_diff = Puppet::FileBucket::File.indirection.find(\n          source_path,\n          :bucket_path => @local_path,\n          :diff_with => checksum_b\n        )\n      elsif file_b\n        tmp_file = ::Tempfile.new('diff')\n        begin\n          restore(tmp_file.path, checksum_a)\n          file_diff = Puppet::Util::Diff.diff(tmp_file.path, file_b)\n        ensure\n          tmp_file.close\n          tmp_file.unlink\n        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","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/file_bucket/dipper.rb#L67-L103","documentation":"Dipper#diff(checksum_a, checksum_b, file_a, file_b) compares two sides. When the first side is a bucket checksum (checksum_a given), the second side must be either checksum_b (another bucket sum) or file_b (a filesystem path). With neither supplied, Puppet::Error asks for a file or checksum to diff with.","triggerScenarios":"Calling dipper.diff(sum_a, nil, nil, nil); CLI misuse such as `puppet filebucket diff <sum>` with no second operand; wrapper code that builds argument lists dynamically and leaves the right-hand side blank when the second input was not provided.","commonSituations":"Scripts that compare a backed-up file against a current file only when the current file exists, passing nil otherwise.","solutions":["Supply a second checksum: `puppet filebucket diff <sum_a> <sum_b>` (Dipper#diff(a, b))","Or compare against a working file path as the fourth argument: Dipper#diff(sum_a, nil, nil, '/tmp/current')","Guard the call site: only invoke diff when checksum_b or file_b is non-nil"],"exampleFix":"# before\ndipper.diff(sum_a, nil, nil, nil)\n# after\ndipper.diff(sum_a, nil, nil, '/etc/puppetlabs/puppet/puppet.conf')","handlingStrategy":"validation","validationCode":"def diffable?(checksum_b, file_b)\n  !checksum_b.nil? || !file_b.nil? || File.exist?(file_b.to_s)\nend\nraise ArgumentError, 'second side required: checksum_b or file_b' unless diffable?(checksum_b, file_b)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat Dipper#diff as requiring two non-nil sides; validate before the call","When comparing against an optional working file, fall back to a checksum of that file instead of nil"],"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"}