Skip to content

Creating a new user with a partner attached failed with "partner invalid" on prod #3337

Description

@kimadactyl

Report

On production: created a new user via the admin invite wizard with Trinity House attached as a partner, and it failed with an error along the lines of "partner invalid". Workaround that succeeded: create the user as a plain citizen first, then attach the partner from the user edit page afterwards.

Investigation so far (2026-07-15)

Could not reproduce locally on current code, logged in as root:

  • Ran the full invite wizard (personal details → permissions → select partner → Invite User) with a valid partner: user created, partner attached correctly.
  • Repeated with a partner record made deliberately invalid (failing current Partner validations, simulating legacy prod data): user still created fine and the partner attached. Rails does not validate unchanged existing HABTM records when saving a new user, so "legacy invalid partner blocks user creation" is ruled out as the mechanism on current code.
  • The server accepts user[partner_ids][] on create for root (UserPolicy#permitted_attributes_for_create) and Admin::UsersController#create attaches them via invite!.
  • AppSignal: no error incidents or retained traces for Admin::UsersController#create, and log retention (24h) has already rolled past the attempt, so the exact prod error text is unrecoverable.

Leads for next time it happens

  1. Capture the exact error message (screenshot ideally) — "partner invalid" vs "Partners is invalid" vs the non-root guard message point at different code paths.
  2. Check the Trinity House record in prod console: Partner.find_by(name: 'Trinity House').tap(&:valid?).errors.full_messages — and whether anything about it is unusual (service areas, tags, hidden state).
  3. Confirm which account/role did the creating. Non-root creators hit validate_partner_relation in Admin::UsersController ("You must assign a Partner to the User…"), a different path from root.
  4. Check which release was deployed at the time of the attempt — the failure may predate a recent admin users redesign deploy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugRelease Drafter category - bug impacting the normal functioning of existing features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions