{"record":{"id":"3f68dfdcc8a324fb","repo":"puppetlabs/puppet","slug":"failed-to-serialize-model-for-key-detai","errorCode":null,"errorMessage":"Failed to serialize %{model} for '%{key}': %{detail}","messagePattern":"Failed to serialize %(.+?) for '%(.+?)': %(.+?)","errorType":"exception","errorClass":"Puppet::Network::FormatHandler::FormatError","httpStatus":null,"severity":"error","filePath":"lib/puppet/network/http/api/indirected_routes.rb","lineNumber":195,"sourceCode":"    result = indirection.save(sent_object, key)\n\n    response.respond_with(200, formatter, formatter.render(result))\n  end\n\n  # Return the first response formatter that didn't cause the yielded\n  # block to raise a FormatError.\n  def first_response_formatter_for(model, request, key, &block)\n    formats = accepted_response_formatters_for(model, request)\n    formatter = formats.find do |format|\n      yield format\n      true\n    rescue Puppet::Network::FormatHandler::FormatError => err\n      msg = _(\"Failed to serialize %{model} for '%{key}': %{detail}\") %\n            { model: model, key: key, detail: err }\n      if Puppet[:allow_pson_serialization]\n        Puppet.warning(msg)\n      else\n        raise Puppet::Network::FormatHandler::FormatError, msg\n      end\n      false\n    end\n\n    return formatter if formatter\n\n    raise Puppet::Network::HTTP::Error::HTTPNotAcceptableError.new(\n      _(\"No supported formats are acceptable (Accept: %{accepted_formats})\") % { accepted_formats: formats.map(&:mime).join(', ') },\n      Puppet::Network::HTTP::Issues::UNSUPPORTED_FORMAT\n    )\n  end\n\n  # Return an array of response formatters that the client accepts and\n  # the server supports.\n  def accepted_response_formatters_for(model_class, request)\n    request.response_formatters_for(model_class.supported_formats)\n  end\n","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/network/http/api/indirected_routes.rb#L177-L213","documentation":"When building a response, the handler tries each format accepted by the client and serializes the model; if serialization raises Puppet::Network::FormatHandler::FormatError, the detail is appended to this message. Behavior then depends on allow_pson_serialization (default false): when true, Puppet logs a warning and tries the next accepted format; when false, the FormatError is re-raised and surfaces as a server-side error. The classic cause is data the chosen format cannot represent, most often rich data asked for as PSON.","triggerScenarios":"A catalog or facts response containing rich data (Sensitive values, Puppet data types, versioned data) requested with Accept: pson, while Puppet[:allow_pson_serialization] = false turns the fallback warning into a hard failure. The %{detail} names the value that failed to serialize.","commonSituations":"Mixed-version infrastructure where old agents request PSON from newer masters; modules that put rich data into catalogs; sites that rely on the default allow_pson_serialization=false hardening while still serving legacy PSON clients.","solutions":["Make clients request a format that can carry the data, e.g. Accept: application/json","Upgrade agents so they no longer depend on PSON serialization","If legacy PSON clients must keep working, set allow_pson_serialization = true in puppet.conf (downgrades the failure to a warning and falls through to other formats)","Read the %{detail} portion of the message to identify exactly which value failed to serialize"],"exampleFix":"# before\ncurl -H 'Accept: pson' \"https://puppet:8140/puppet/v3/catalog/mynode?environment=production\"\n\n# after\ncurl -H 'Accept: application/json' \"https://puppet:8140/puppet/v3/catalog/mynode?environment=production\"","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"begin\n  response = http.get(\"/puppet/v3/catalog/#{certname}\",\n                      params: { environment: env },\n                      headers: { 'Accept' => 'application/json' })\nrescue Puppet::Network::FormatHandler::FormatError => e\n  # e.message includes the %{detail} naming the unserializable value\n  Puppet.err(\"catalog serialization failed for #{certname}: #{e.message}\")\n  raise\nend","preventionTips":["Standardize Accept: application/json across all clients","Avoid rich data in catalogs while legacy PSON clients remain in the fleet","Keep agent and server versions in step during format migrations"],"tags":["serialization","format","pson","catalog"],"backgroundTag":"serialization-failed","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}