docusealco/docuseal · error · Submitters::NormalizeValues::InvalidDefaultValue

Invalid #{type} value

Error message

Invalid #{type} value

What it means

Submitters::NormalizeValues#find_or_build_attachment (lib/submitters/normalize_values.rb:205) raises InvalidDefaultValue 'Invalid <type> value' unconditionally when purpose == :bulk. Attachment-typed fields (signature, initials, image, stamp, file...) simply cannot carry preset values through the bulk/CSV import path — the guard fires before any format inspection of the value.

Source

Thrown at lib/submitters/normalize_values.rb:205

          attachments.find { |a| a.blob_id == new_attachment.blob_id } || new_attachment
        end

        [new_attachments.map(&:uuid), new_attachments]
      else
        new_attachment = find_or_build_attachment(value, field, account, for_submitter:, purpose:)

        existing_attachment = attachments.find { |a| a.blob_id == new_attachment.blob_id }

        attachment = existing_attachment || new_attachment

        [attachment.uuid, attachment]
      end
    end

    def find_or_build_attachment(value, field, account, for_submitter: nil, purpose: nil)
      type = field['type']

      raise InvalidDefaultValue, "Invalid #{type} value" if purpose == :bulk

      blob =
        if value.match?(%r{\Ahttps?://})
          raise InvalidDefaultValue, "Invalid #{type} value" unless purpose == :api

          find_or_create_blob_from_url(account, value)
        elsif type.in?(%w[signature initials]) && value.length < 60
          find_or_create_blob_from_text(account, value, type)
        elsif (data = Base64.decode64(value.sub(BASE64_PREFIX_REGEXP, ''))) &&
              (mime_type = Marcel::MimeType.for(data)).exclude?('octet-stream')
          find_or_create_blob_from_base64(account, data, type, mime_type:)
        elsif type == 'image' && (value.starts_with?('<html>') || value.starts_with?('<!DOCTYPE'))
          raise InvalidDefaultValue, "Invalid #{type} value" unless purpose == :api

          find_or_create_blob_from_html(account, value, field)
        else
          raise InvalidDefaultValue, "Invalid value, url, base64 or text < 60 chars is expected: #{value.first(200)}..."
        end

View on GitHub (pinned to 004a22c1c8)

Solutions

  1. Remove attachment-field values (signature, initials, image, stamp, file) from bulk import payloads — leave those fields for signers to complete.
  2. Use the JSON API (purpose :api) to pre-fill attachments via base64 or URL, where they are supported.
  3. Validate your CSV/attrs against template field types before submitting and drop unsupported columns client-side.

Example fix

# before (bulk import row with attachment value)
{ 'submitters' => [{ 'email' => 'a@b.c', 'values' => { signature_field_uuid => 'data:image/png;base64,...' } }] }

# after (attachment left for the signer)
{ 'submitters' => [{ 'email' => 'a@b.c', 'values' => { text_field_uuid => 'John' } }] }
Defensive patterns

Strategy: validation

Validate before calling

# Strip attachment-typed field values before any bulk import
ATTACHMENT_TYPES = %w[signature initials image stamp file].freeze

def bulk_safe?(template_fields, values)
  values.keys.none? do |uuid|
    (f = template_fields.find { |e| e['uuid'] == uuid }) && ATTACHMENT_TYPES.include?(f['type'])
  end
end

Try / catch

begin
  Submissions::CreateFromSubmitters.call(template:, user:, submissions_attrs:, source: 'bulk', submitters_order:)
rescue Submitters::NormalizeValues::InvalidDefaultValue => e
  render json: { error: e.message }, status: :unprocessable_entity
end

Prevention

When it happens

Trigger: Bulk submission creation (CSV import) whose per-signer values column contains a value for a signature/image/stamp/file field; any code path calling NormalizeValues with purpose: :bulk and a default/field value for an attachment field.

Common situations: CSV templates exported from the API examples including attachment columns; customers migrating paper workflows expecting pre-filled signature images; integrations reusing the same payload for the API and the bulk importer.

Related errors


AI-assisted analysis of docusealco/docuseal@004a22c1c8 (2026-08-21). Data as JSON: /api/errors/563578c0dd30cc77. Report an issue: GitHub.