{"record":{"id":"a0d7c1b5e607d5dd","repo":"docusealco/docuseal","slug":"invalid-value-url-base64-or-text-60-chars-is-e","errorCode":null,"errorMessage":"Invalid value, url, base64 or text < 60 chars is expected: #{value.first(200)}...","messagePattern":"Invalid value, url, base64 or text < 60 chars is expected: #(.+?)\\.\\.\\.","errorType":"validation","errorClass":"Submitters::NormalizeValues::InvalidDefaultValue","httpStatus":422,"severity":"error","filePath":"lib/submitters/normalize_values.rb","lineNumber":222,"sourceCode":"\n      raise InvalidDefaultValue, \"Invalid #{type} value\" if purpose == :bulk\n\n      blob =\n        if value.match?(%r{\\Ahttps?://})\n          raise InvalidDefaultValue, \"Invalid #{type} value\" unless purpose == :api\n\n          find_or_create_blob_from_url(account, value)\n        elsif type.in?(%w[signature initials]) && value.length < 60\n          find_or_create_blob_from_text(account, value, type)\n        elsif (data = Base64.decode64(value.sub(BASE64_PREFIX_REGEXP, ''))) &&\n              (mime_type = Marcel::MimeType.for(data)).exclude?('octet-stream')\n          find_or_create_blob_from_base64(account, data, type, mime_type:)\n        elsif type == 'image' && (value.starts_with?('<html>') || value.starts_with?('<!DOCTYPE'))\n          raise InvalidDefaultValue, \"Invalid #{type} value\" unless purpose == :api\n\n          find_or_create_blob_from_html(account, value, field)\n        else\n          raise InvalidDefaultValue, \"Invalid value, url, base64 or text < 60 chars is expected: #{value.first(200)}...\"\n        end\n\n      attachment = for_submitter.attachments.find_by(blob_id: blob.id) if for_submitter\n\n      attachment ||= ActiveStorage::Attachment.new(\n        blob:,\n        name: 'attachments'\n      )\n\n      attachment\n    end\n\n    def find_or_create_blob_from_html(_account, value, _field)\n      raise InvalidDefaultValue, \"HTML content is not allowed: #{value.first(200)}...\"\n    end\n\n    def find_or_create_blob_from_base64(account, data, type, mime_type: nil)\n      checksum = Digest::MD5.base64digest(data)","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/docusealco/docuseal/blob/004a22c1c88109c7ba0b567df011a8cb13894001/lib/submitters/normalize_values.rb#L204-L240","documentation":"Submitters::NormalizeValues#find_or_build_attachment (lib/submitters/normalize_values.rb:222) raises InvalidDefaultValue listing the expected formats when the value matches none of them: not an http(s) URL, not a short typed string for signature/initials (< 60 chars), not base64 that decodes to a recognized non-'octet-stream' MIME type, and not HTML. The message echoes the first 200 chars of the offending value for diagnosis.","triggerScenarios":"Base64 that decodes to bytes Marcel::MimeType.for reports as application/octet-stream (generic binary, wrong padding, corrupted data URI); a >60-char signature value that is not valid base64; a data URI with an unparsable prefix; stray whitespace/newlines breaking decode64; text sent for a non-signature field where typed text is not accepted.","commonSituations":"Frontends sending ArrayBuffer or blob references instead of base64; copy-pasting base64 with line wraps; uploads of arbitrary binary (docx renamed, encrypted blobs) as image values; missing 'data:...;base64,' prefix handling (BASE64_PREFIX_REGEXP strips it only when present).","solutions":["For images/signatures send a proper data URI: 'data:image/png;base64,<clean single-line base64>'.","For signature/initials typed text, keep it under 60 characters so it renders with the font-image generator.","Verify locally that Base64.strict_decode64 succeeds and the bytes' MIME is a concrete type (image/png, image/jpeg, application/pdf) before submitting.","Strip whitespace/newlines from base64 before sending."],"exampleFix":"# before\n{ 'default_value' => blob_object.to_s } # '[object Blob]' — matches no branch\n\n# after\n{ 'default_value' => \"data:image/png;base64,#{base64_single_line}\" }","handlingStrategy":"validation","validationCode":"# Verify the value matches one accepted branch before submitting\nrequire 'base64'\nrequire 'marcel'\n\ndef acceptable_attachment_value?(value, type)\n  return true if value.match?(%r{\\Ahttps?://}) # API purpose only\n  return true if type.in?(%w[signature initials]) && value.length < 60\n\n  data = Base64.decode64(value.sub(%r{\\Adata:[^;]+;base64,}, ''))\n  data.present? && !Marcel::MimeType.for(data).include?('octet-stream')\nrescue ArgumentError\n  false\nend","typeGuard":null,"tryCatchPattern":"begin\n  Submitters::NormalizeValues.normalize_attachment_value(value, field, account, attachments, purpose:)\nrescue Submitters::NormalizeValues::InvalidDefaultValue => e\n  render json: { error: e.message }, status: :unprocessable_entity # message echoes first 200 chars\nend","preventionTips":["Send single-line base64 with no wrapped whitespace; include the data:...;base64, prefix.","Typed signature/initials text must stay under 60 characters.","Sniff the MIME locally (Marcel) and require a concrete type before upload.","Do not send serialized objects/blob handles as values."],"tags":["docuseal","default-value","base64","params-validation"],"backgroundTag":"default-value-validation-failed","analyzedSha":"004a22c1c88109c7ba0b567df011a8cb13894001","analyzedAt":"2026-08-21T13:38:23.343Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}