getredash/redash · error

Error updating record

Error message

Error updating record

What it means

A catch-all for IntegrityError raised while updating a user row when the error text does not mention "email". The database rejected the write because some other constraint (non-null, unique, FK, length) was violated by the submitted fields, and the handler surfaces it as HTTP 400 with a generic message.

Source

Thrown at redash/handlers/users.py:263

        try:
            self.update_model(user, params)
            models.db.session.commit()

            if needs_to_verify_email:
                send_verify_email(user, self.current_org)

            # The user has updated their email or password. This should invalidate all _other_ sessions,
            # forcing them to log in again. Since we don't want to force _this_ session to have to go
            # through login again, we call `login_user` in order to update the session with the new identity details.
            if current_user.id == user.id:
                login_user(user, remember=True)
        except IntegrityError as e:
            if "email" in str(e):
                message = "Email already taken."
            else:
                message = "Error updating record"

            abort(400, message=message)

        self.record_event(
            {
                "action": "edit",
                "object_id": user.id,
                "object_type": "user",
                "updated_fields": list(params.keys()),
            }
        )

        return user.to_dict(with_api_key=is_admin_or_owner(user_id))

    @require_admin
    def delete(self, user_id):
        user = models.User.get_by_id_and_org(user_id, self.current_org)
        # admin cannot delete self; current user is an admin (`@require_admin`)
        # so just check user id
        if user.id == current_user.id:

View on GitHub (pinned to ca79fe988d)

Solutions

  1. Inspect the database server logs or enable SQLAlchemy echo to see the underlying IntegrityError cause
  2. Validate all submitted fields (non-empty required values, sane lengths) before the request
  3. Run the latest migrations (bin/run ./manage.py database upgrade) so schema and code match
  4. Reproduce with a minimal payload to isolate which field triggers the constraint

Example fix

// before
{"name": null}  // 400 Error updating record
// after
{"name": "Jane Doe"}
Defensive patterns

Strategy: validation

Validate before calling

for field in ("name",):
    v = payload.get(field)
    assert v is not None and str(v).strip() != "", f"{field} required"
    assert len(str(v)) <= 255, f"{field} too long"

Try / catch

resp = requests.post(url, json=payload, headers=hdrs)
if resp.status_code == 400 and resp.json().get("message") == "Error updating record":
    logger.error("IntegrityError updating user %s: %s", uid, payload)  # then check DB logs

Prevention

When it happens

Trigger: POST /api/users/<id> with fields that violate a column constraint other than the email unique constraint — e.g. a null/empty required field, an over-length value, or a foreign key to a nonexistent row (depending on schema version).

Common situations: Schema drift after a Redash upgrade added constraints (migrations not applied); clients sending nulls or empty strings for required columns; legacy scripts posting fields that newer versions constrain.

Related errors


AI-assisted analysis of getredash/redash@ca79fe988d (2026-08-28). Data as JSON: /api/errors/b576624582f4ee3a. Report an issue: GitHub.