#4446 Setting a flag on a commit fails with EDBERROR
Closed: Fixed 4 years ago by pingou. Opened 4 years ago by mikeb.

When trying to set a flag on a commit, Pagure responds with a 400 BAD REQUEST, and the payload says:

{
  "error": "An error occurred at the database level and prevent the action from reaching completion",
  "error_code": "EDBERROR"
}

The request was:

$ curl -i -X POST -H "Authorization: token XXXX" --data-urlencode status=success --data-urlencode percent=100 --data-urlencode 'comment=Build passed.' --data-urlencode username=c3i-jenkins --data-urlencode uid=ci-post-merge --data-urlencode 'url=https://jenkins-mbs-koji-int-test.cloud.paas.psi.redhat.com/job/mbs-koji-int-test/job/mbs-koji-int-test-mbs-postmerge/3/' https://pagure.io/api/0/fm-orchestrator/c/ee2ef77fe9e4d59b2b7c0c1361b7dc6f91908c19/flag
HTTP/1.1 400 BAD REQUEST
Date: Wed, 01 May 2019 15:29:56 GMT
Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips mod_wsgi/3.4 Python/2.7.5
Set-Cookie: pagure=XXXX; Exp\
ires=Sat, 01-Jun-2019 15:29:56 GMT; Secure; HttpOnly; Path=/
X-Frame-Options: ALLOW-FROM https://pagure.io/
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Referrer-Policy: same-origin
Content-Security-Policy: default-src 'self' https:; script-src 'self' 'unsafe-eval' 'unsafe-inline' https://apps.fedoraproject.org; style-src 'self' 'unsafe-inline' https://apps.fedoraproject.org
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Content-Length: 132
Connection: close
Content-Type: application/json

{
  "error": "An error occurred at the database level and prevent the action from reaching completion",
  "error_code": "EDBERROR"
}

Was this transient or does it persist?

Metadata Update from @pingou:
- Issue tagged with: bug

4 years ago

This is the error I'm seeing in the logs:

IntegrityError: (IntegrityError) duplicate key value violates unique constraint "commit_flags_uid_key"
DETAIL:  Key (uid)=(ci-post-merge) already exists.

@pingou So the uid needs to be unique per-commit? The Pagure docs suggest I can use whatever I want, without worrying about uniqueness.

Ahhh, rereading, it looks like it needs to be project-specific. So if I used something like ci-post-merge-mbs for all commits to the fm-orchestrator repo, would that work?

Hmmm, a unique constraint is present on the uid column in the Alembic script:

https://pagure.io/pagure/blob/master/f/alembic/versions/2b626a16542e_commit_flag.py#_25

but not present in the SQLAlchemy model:

https://pagure.io/pagure/blob/master/f/pagure/lib/model.py#_2419

This constraint is stronger than (and redundant with) the (commit_hash, uid) constraint:

https://pagure.io/pagure/blob/master/f/pagure/lib/model.py#_2436

Should the unique constraint on just uid be removed?

Should the unique constraint on just uid be removed?

I think so

Metadata Update from @pingou:
- Issue assigned to pingou
- Issue set to the milestone: 5.6

4 years ago

@pingou Thanks! Has this change been deployed?

@pingou Thanks! Has this change been deployed?

No, it will be in 5.6, hopefully released soon :)

Login to comment on this ticket.

Metadata
Related Pull Requests
  • #4459 Merged 4 years ago