{"record":{"id":"c31db62d08b29bd4","repo":"puppetlabs/puppet","slug":"find-uri-resulted-in-404-with-the-message-bo-c31db6","errorCode":null,"errorMessage":"Find %{uri} resulted in 404 with the message: %{body}","messagePattern":"Find %(.+?) resulted in 404 with the message: %(.+?)","errorType":"http","errorClass":"Puppet::Error","httpStatus":404,"severity":"error","filePath":"lib/puppet/indirector/file_content/rest.rb","lineNumber":32,"sourceCode":"    url = URI.parse(Puppet::Util.uri_encode(request.uri))\n    session = Puppet.lookup(:http_session)\n    api = session.route_to(:fileserver, url: url)\n\n    api.get_file_content(\n      path: Puppet::Util.uri_unescape(url.path),\n      environment: request.environment.to_s\n    ) do |data|\n      content << data\n    end\n\n    Puppet::FileServing::Content.from_binary(content.string)\n  rescue Puppet::HTTP::ResponseError => e\n    if e.response.code == 404\n      return nil unless request.options[:fail_on_404]\n\n      _, body = parse_response(e.response)\n      msg = _(\"Find %{uri} resulted in 404 with the message: %{body}\") % { uri: elide(e.response.url.path, 100), body: body }\n      raise Puppet::Error, msg\n    else\n      raise convert_to_http_error(e.response)\n    end\n  end\nend\n","sourceCodeStart":14,"sourceCodeEnd":38,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/indirector/file_content/rest.rb#L14-L38","documentation":"The REST terminus for the file_content indirection wraps HTTP 404 from the Puppet fileserver API. By default 404 returns nil (treated as file absent); when the request carries options[:fail_on_404], which Puppet sets when resolving file sources during catalog application, it raises Puppet::Error embedding the elided URI path and the server's parsed message body so the missing source is reported loudly instead of silently yielding nil.","triggerScenarios":"A file resource with source 'puppet:///modules/<mod>/<path>' where the file does not exist on the server in the node's environment; wrong module name or mount; Ruby calls to Puppet::FileServing::Content.indirection.find(uri, fail_on_404: true) for a missing file.","commonSituations":"Files deleted from a module but still referenced by manifests; environments out of sync (file merged to production while the agent runs a feature branch); case mismatches in paths on case-sensitive servers; fileserver mount renamed.","solutions":["Verify the file exists server-side: puppet:///modules/mod/path maps to environments/<env>/modules/mod/files/path on the Puppet server.","Confirm the node's environment matches the environment that contains the file.","Re-check spelling and case of the source URI and module name.","If absence is legitimate and you call the API directly, omit fail_on_404 so the lookup returns nil instead of raising."],"exampleFix":"# manifest - before\nfile { '/etc/app/app.conf':\n  source => 'puppet:///modules/app/etc/app.con', # typo\n}\n\n# after\nfile { '/etc/app/app.conf':\n  source => 'puppet:///modules/app/etc/app.conf',\n}","handlingStrategy":"fallback","validationCode":"# do not opt into failing on absence unless absence is fatal\ncontent = Puppet::FileServing::Content.indirection.find(uri) # returns nil on 404\nif content.nil?\n  content = Puppet::FileServing::Content.from_binary(File.binread('/etc/app.conf.default'))\nend","typeGuard":null,"tryCatchPattern":"begin\n  content = Puppet::FileServing::Content.indirection.find(uri, fail_on_404: true)\nrescue Puppet::Error => e\n  Puppet.warning(uri + ' unavailable, using default')\n  content = Puppet::FileServing::Content.from_binary(DEFAULT)\nend","preventionTips":["Run catalog tests that resolve every file source in CI before deploy.","Keep environments in sync so sources exist where agents run.","Audit puppet:/// URIs for typos and case mismatches with lint checks."],"tags":["puppet","fileserver","http-404","catalog-compilation","modules"],"backgroundTag":"http-404-not-found","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}