{"record":{"id":"91fcd559ae0598ec","repo":"puppetlabs/puppet","slug":"no-request-key-specified-in-uri","errorCode":null,"errorMessage":"No request key specified in %{uri}","messagePattern":"No request key specified in %(.+?)","errorType":"http","errorClass":"Puppet::Network::HTTP::Error::HTTPBadRequestError","httpStatus":400,"severity":"error","filePath":"lib/puppet/network/http/api/indirected_routes.rb","lineNumber":106,"sourceCode":"\n    unless Puppet::Node::Environment.valid_name?(environment)\n      raise Puppet::Network::HTTP::Error::HTTPBadRequestError, _(\"The environment must be purely alphanumeric, not '%{environment}'\") % { environment: environment }\n    end\n\n    configured_environment = Puppet.lookup(:environments).get(environment)\n    unless configured_environment.nil?\n      configured_environment = configured_environment.override_from_commandline(Puppet.settings)\n      params[:environment] = configured_environment\n    end\n\n    if configured_environment.nil? && indirection.terminus.require_environment?\n      raise Puppet::Network::HTTP::Error::HTTPNotFoundError, _(\"Could not find environment '%{environment}'\") % { environment: environment }\n    end\n\n    params.delete(:bucket_path)\n\n    if key == \"\" or key.nil?\n      raise Puppet::Network::HTTP::Error::HTTPBadRequestError, _(\"No request key specified in %{uri}\") % { uri: uri }\n    end\n\n    [indirection, method, key, params]\n  end\n\n  private\n\n  # Execute our find.\n  def do_find(indirection, key, params, request, response)\n    result = indirection.find(key, params)\n    unless result\n      raise Puppet::Network::HTTP::Error::HTTPNotFoundError.new(_(\"Could not find %{value0} %{key}\") % { value0: indirection.name, key: key }, Puppet::Network::HTTP::Issues::RESOURCE_NOT_FOUND)\n    end\n\n    rendered_result = result\n\n    rendered_format = first_response_formatter_for(indirection.model, request, key) do |format|\n      if result.respond_to?(:render)","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/network/http/api/indirected_routes.rb#L88-L124","documentation":"The indirection key is the path segment(s) after the indirection name in the URI: the certname for catalog/facts/report endpoints, the file path for file endpoints. If it is missing or empty (trailing-slash URL, blank variable), the handler raises HTTP 400 'No request key specified in <uri>', echoing the URI back to identify the malformed call.","triggerScenarios":"GET /puppet/v3/catalog/ with no node name; PUT /puppet/v3/report/ with nothing after the indirection; GET /puppet/v3/file_content/files/ with nothing after the mount; URLs where the key segment was lost to encoding, rewriting or an empty interpolation.","commonSituations":"Templated URL builders that leave the key blank when a variable is nil; manual curl tests ending in a trailing slash; proxies stripping path segments; scripts iterating an empty list of node names.","solutions":["Append the key: the node name for catalog/facts/reports, the module path for file endpoints","Guard URL builders so they fail early when the key variable is nil or empty instead of emitting a broken URL","Check path rewriting so the segment after the indirection name is not dropped","URL-encode keys containing special characters so they are not parsed away"],"exampleFix":"# before\ncurl \"https://puppet:8140/puppet/v3/catalog/?environment=production\"\n\n# after\ncurl \"https://puppet:8140/puppet/v3/catalog/mynode.example.com?environment=production\"","handlingStrategy":"validation","validationCode":"def indirected_uri(indirection, key, environment)\n  raise ArgumentError, 'request key required' if key.nil? || key.to_s.empty?\n  \"/puppet/v3/#{indirection}/#{URI.encode_www_form_component(key)}?environment=#{environment}\"\nend","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never build these URLs by concatenation with unchecked nils","Smoke-test generated URLs with URI.parse and assert every segment is non-empty"],"tags":["http","uri","missing-parameter","rest-api"],"backgroundTag":"missing-path-parameter","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}