Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UniqueConstraintViolationException inside log when adding trusted servers using testing api #131

Closed
skshetry opened this issue Jan 3, 2020 · 0 comments · Fixed by #153
Closed
Assignees

Comments

@skshetry
Copy link
Member

skshetry commented Jan 3, 2020

Sample log from https://drone.owncloud.com/owncloud/phoenix/7515/24/13:

{"reqId":"2gbt7aFeIjaM3FErZKjb","level":3,"time":"2020-01-03T06:48:02+00:00","remoteAddr":"172.23.0.10","user":"admin","app":"PHP","method":"POST","url":"\/ocs\/v2.php\/apps\/testing\/api\/v1\/trustedservers?format=json","message":"Doctrine\\DBAL\\Exception\\UniqueConstraintViolationException: An exception occurred while executing 'INSERT INTO `oc_trusted_servers` (`url`, `url_hash`) VALUES(?, ?)' with params [\"http:\\\/\\\/owncloud\", \"668b5fcda851fe516fef14e82973beffe32f385a\"]:\n\nSQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '668b5fcda851fe516fef14e82973beffe32f385a' for key 'url_hash' at \/var\/www\/owncloud\/server\/lib\/composer\/doctrine\/dbal\/lib\/Doctrine\/DBAL\/Driver\/AbstractMySQLDriver.php#55"}

Analysis

This happens because we never check if the trusted server is already added. We just catch this error and return happily (which we should). The better way would be to check if the trusted server exists in the DB and then, make a decision (i.e. add or do nothing).
This pollutes the log, and could make debugging harder when checking CI failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants