{"record":{"id":"d297fa36540185e7","repo":"we-promise/sure","slug":"model-does-not-support-pdf-processing-effective","errorCode":null,"errorMessage":"Model does not support PDF processing: #{effective_model}","messagePattern":"Model does not support PDF processing: #(.+?)","errorType":"exception","errorClass":"Provider::Anthropic::Error","httpStatus":null,"severity":"error","filePath":"app/models/provider/anthropic.rb","lineNumber":160,"sourceCode":"        family: family\n      ).enhance_merchants\n\n      upsert_langfuse_trace(trace: trace, output: result.map(&:to_h))\n\n      result\n    end\n  end\n\n  def supports_pdf_processing?(model: @default_model)\n    return true if custom_endpoint?\n\n    VISION_CAPABLE_MODEL_PREFIXES.any? { |prefix| model.to_s.start_with?(prefix) }\n  end\n\n  def process_pdf(pdf_content:, model: \"\", family: nil)\n    with_provider_response do\n      effective_model = model.presence || @default_model\n      raise Error, \"Model does not support PDF processing: #{effective_model}\" unless supports_pdf_processing?(model: effective_model)\n\n      trace = create_langfuse_trace(\n        name: \"anthropic.process_pdf\",\n        input: { pdf_size: pdf_content&.bytesize }\n      )\n\n      result = PdfProcessor.new(\n        client,\n        model: effective_model,\n        pdf_content: pdf_content,\n        langfuse_trace: trace,\n        family: family\n      ).process\n\n      upsert_langfuse_trace(trace: trace, output: result.to_h)\n\n      result\n    end","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/we-promise/sure/blob/e69894adb92547273377398c15f45c979cd9416a/app/models/provider/anthropic.rb#L142-L178","documentation":"process_pdf raises Error unless supports_pdf_processing?(model:) is true. On the standard API (no custom base_url) that method checks the model ID against VISION_CAPABLE_MODEL_PREFIXES; only models starting with one of those prefixes are considered able to handle native PDF document blocks. Custom endpoints (custom_endpoint?) bypass the gate entirely because proxies validate model support themselves.","triggerScenarios":"Calling process_pdf with model: \"\" falling through to a @default_model whose ID doesn't start with any vision-capable prefix — e.g. an old/new/typo'd model ID configured in settings while using api.anthropic.com directly. The check runs before the request, so no API call is wasted.","commonSituations":"Settings offer a free-text model field and the user enters a legacy (claude-2), non-vision, or misspelled model; Anthropic ships a new model generation before the prefix list is updated; a model ID copied from a proxy gateway (with gateway-specific naming) used against the direct API.","solutions":["Switch to a vision-capable Claude model (a current Sonnet/Opus ID) in your Anthropic provider settings — those match the allowed prefixes.","If you are routing through a compatible gateway whose models do support PDFs, configure the custom base_url so custom_endpoint? bypasses the prefix gate.","If the model genuinely supports PDFs on the direct API but the prefix list is stale, update VISION_CAPABLE_MODEL_PREFIXES in the provider and add a test."],"exampleFix":"# before\nprovider.process_pdf(pdf_content: pdf, model: \"claude-2\")\n# => Model does not support PDF processing: claude-2\n\n# after\nprovider.process_pdf(pdf_content: pdf, model: \"claude-sonnet-4-6\")\n# or gate first:\nif provider.supports_pdf_processing?(model: chosen_model)\n  provider.process_pdf(pdf_content: pdf, model: chosen_model)\nend","handlingStrategy":"type-guard","validationCode":"if provider.supports_pdf_processing?(model: chosen_model)\n  provider.process_pdf(pdf_content: pdf, model: chosen_model)\nelse\n  render_error(\"#{chosen_model} cannot process PDFs; pick a vision-capable Claude model\")\nend","typeGuard":"def pdf_capable?(provider, model)\n  provider.supports_pdf_processing?(model: model)\nend\n# true even on custom endpoints (gate bypassed); false for non-vision prefix IDs on the direct API","tryCatchPattern":"begin\n  provider.process_pdf(pdf_content: pdf, model: model)\nrescue Provider::Anthropic::Error => e\n  # config error: fix model, don't retry\n  flash.now[:alert] = e.message\nend","preventionTips":["Restrict the settings model picker to known vision-capable models rather than free text.","Call supports_pdf_processing? before showing/enabling PDF upload UI.","Keep VISION_CAPABLE_MODEL_PREFIXES current when new model generations ship."],"tags":["anthropic","llm","pdf","model-capability","vision-models"],"backgroundTag":"unsupported-model-capability","analyzedSha":"e69894adb92547273377398c15f45c979cd9416a","analyzedAt":"2026-08-21T18:22:41.165Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}