docusealco/docuseal · error · Submissions::CreateFromSubmitters::BaseError

Defined more signing parties than in template

Error message

Defined more signing parties than in template

What it means

Submissions::CreateFromSubmitters raises BaseError 'Defined more signing parties than in template' (lib/submissions/create_from_submitters.rb:80) when the built submission ends with more Submitter records than the template defines parties. After each entry is matched to a template party (or several parties merged via roles:), the code guards the invariant that a submission cannot gain parties the template does not have.

Source

Thrown at lib/submissions/create_from_submitters.rb:80

                                                         'invite_via_field_uuid')

          template_submitter['order'] = submitter_attrs['order'] if submitter_attrs['order'].present?

          submission.template_submitters << template_submitter

          is_order_sent = submitters_order == 'random' ||
                          (template_submitter['order'] || submitter_attrs[:index] || index).zero?

          build_submitter(submission:, attrs: submitter_attrs,
                          uuid:, is_order_sent:, user:, params:,
                          preferences: preferences.merge(submission_preferences))
        end

        maybe_set_dynamic_documents(submission)
        maybe_set_template_fields(submission, attrs[:submitters], with_template:, new_fields:)

        if submission.submitters.size > template.submitters.size
          raise BaseError, 'Defined more signing parties than in template'
        end

        if template.preferences['validate_unique_submitters'] == true
          submission_emails = submission.submitters.filter_map(&:email)

          raise BaseError, 'Recipient emails should differ' if submission_emails.uniq.size != submission_emails.size
        end

        next if submission.submitters.blank?

        maybe_add_invite_submitters(submission, template, attrs[:submitters])

        assign_submitters_is_viewer(submission)

        submission.template = nil unless with_template

        submission.tap(&:save!)
      end

View on GitHub (pinned to 004a22c1c8)

Solutions

  1. Cap your submitters array at template.submitters.size — fetch the template and count its parties before building the request.
  2. If one person must sign for multiple roles, merge them into a single entry with roles: ['Role A', 'Role B'] so the party count stays within the template.
  3. Re-pull the template after edits and regenerate the request payload; removed roles still counted client-side are the usual cause.
  4. Rescue Submissions::CreateFromSubmitters::BaseError and report a 422 with the message so callers can fix their payload.

Example fix

# before
submitters_attrs = external_signers.map { |s| { role: s.role, email: s.email } } # may exceed parties

# after
max = template.submitters.size
submitters_attrs = external_signers.first(max).map { |s| { role: s.role, email: s.email } }
Defensive patterns

Strategy: validation

Validate before calling

# Guard before calling: never send more parties than the template defines
party_count = template.submitters.size
raise ArgumentError, "at most #{party_count} submitters allowed" if submitter_entries.size > party_count

Try / catch

begin
  Submissions::CreateFromSubmitters.call(template:, user:, submissions_attrs:, source:, submitters_order:)
rescue Submissions::CreateFromSubmitters::BaseError => e
  render json: { error: e.message }, status: :unprocessable_entity # 'Defined more signing parties than in template'
end

Prevention

When it happens

Trigger: POST /api/submissions with a submitters array longer than template.submitters where every entry matches a different party by index/role/uuid (e.g. 3 entries against a 2-party template); duplicate entries each resolving to distinct template parties; combined with maybe_add_invite_submitters adding invite-linked parties that push the count over.

Common situations: Client apps looping over their own signer list without comparing against the template's party count; templates edited down (role removed) while the integration still sends the old number of signers; assuming unmatched extra entries are silently ignored.

Related errors


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