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

NotNullConstraintViolation when Sharing to User #1375

Closed
3 tasks done
simonspa opened this issue May 23, 2021 · 4 comments · Fixed by #1406
Closed
3 tasks done

NotNullConstraintViolation when Sharing to User #1375

simonspa opened this issue May 23, 2021 · 4 comments · Fixed by #1406
Labels
API Impact API/Backend code bug

Comments

@simonspa
Copy link

IMPORTANT

Read and tick the following checkbox after you have created the issue or place an x inside the brackets ;)

  • I have read the CONTRIBUTING.md and followed the provided tips
  • I accept that the issue will be closed without comment if I do not check here
  • I accept that the issue will be closed without comment if I do not fill out all items in the issue template.

Explain the Problem

I am trying out the new 16-beta1 and wanted to test the sharing functionality. After clicking the share symbol and selecting the user, I get an error displayed and the error log: (full log basted below)

Doctrine\DBAL\Exception\NotNullConstraintViolationException: An exception occurred while executing a query: SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "id" violates not-null constraint DETAIL: Failing row contains (null, ca16132a23f0963a999cce330076e299, 497680852237d14e545aa365cdaf1bd3, b41a8005b306ebf806a6d2c15ddb5097, f, fraudsters redirected email and web traffic destined for several..., https://krebsonsecurity.com/?p=53649, https://krebsonsecurity.com/2020/11/godaddy-employees-used-in-at..., GoDaddy Employees Used in Attacks on Multiple Cryptocurrency Ser..., BrianKrebs, 1605982549, <p>Fraudsters redirected email and web traffic destined for seve..., null, null, null, null, 54, t, f, 1621765946715399, null, smn).

Steps to Reproduce

Explain what you did to encounter the issue

  1. Use 16-beta1
  2. Try to share article
  3. Observe error

System Information

  • News app version: 16-beta1
  • Nextcloud version: 21.0.2
  • Cron type: Cron
  • PHP version: 8.0
  • Database and version: PostgreSQL 12.6
  • Browser and version: Firefox 88
  • OS and version: Ubuntu 20.10
Contents of nextcloud/data/nextcloud.log
{"reqId":"jSXYUnJESl9saIdiRhgq","level":3,"time":"2021-05-23T10:32:26+00:00","remoteAddr":"127.0.0.1","user":"smn","app":"index","method":"POST","url":"/apps/news/items/10772/share/test","message":{"Exception":"Doctrine\\DBAL\\Exception\\NotNullConstraintViolationException","Message":"An exception occurred while executing a query: SQLSTATE[23502]: Not null violation: 7 ERROR:  null value in column \"id\" violates not-null constraint\nDETAIL:  Failing row contains (null, ca16132a23f0963a999cce330076e299, 497680852237d14e545aa365cdaf1bd3, b41a8005b306ebf806a6d2c15ddb5097, f, fraudsters redirected email and web traffic destined for several..., https://krebsonsecurity.com/?p=53649, https://krebsonsecurity.com/2020/11/godaddy-employees-used-in-at..., GoDaddy Employees Used in Attacks on Multiple Cryptocurrency Ser..., BrianKrebs, 1605982549, <p>Fraudsters redirected email and web traffic destined for seve..., null, null, null, null, 54, t, f, 1621765946715399, null, smn).","Code":7,"Trace":[{"file":"/home/simonspa/software/nextcloud_server/3rdparty/doctrine/dbal/src/Connection.php","line":1728,"function":"convert","class":"Doctrine\\DBAL\\Driver\\API\\PostgreSQL\\ExceptionConverter","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/3rdparty/doctrine/dbal/src/Connection.php","line":1667,"function":"handleDriverException","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/3rdparty/doctrine/dbal/src/Connection.php","line":1146,"function":"convertExceptionDuringQuery","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/lib/private/DB/Connection.php","line":257,"function":"executeStatement","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":213,"function":"executeStatement","class":"OC\\DB\\Connection","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/lib/private/DB/QueryBuilder/QueryBuilder.php","line":287,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/lib/public/AppFramework/Db/QBMapper.php","line":135,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->"},{"file":"/home/simonspa/software/nextcloud-news/lib/Db/NewsMapperV2.php","line":76,"function":"insert","class":"OCP\\AppFramework\\Db\\QBMapper","type":"->"},{"file":"/home/simonspa/software/nextcloud-news/lib/Service/ItemServiceV2.php","line":110,"function":"insert","class":"OCA\\News\\Db\\NewsMapperV2","type":"->"},{"file":"/home/simonspa/software/nextcloud-news/lib/Service/ShareService.php","line":137,"function":"insertOrUpdate","class":"OCA\\News\\Service\\ItemServiceV2","type":"->"},{"file":"/home/simonspa/software/nextcloud-news/lib/Controller/ItemController.php","line":342,"function":"shareItemWithUser","class":"OCA\\News\\Service\\ShareService","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/lib/private/AppFramework/Http/Dispatcher.php","line":218,"function":"share","class":"OCA\\News\\Controller\\ItemController","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/lib/private/AppFramework/Http/Dispatcher.php","line":127,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/home/simonspa/software/nextcloud_server/lib/base.php","line":993,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/index.php","line":37,"function":"handleRequest","class":"OC","type":"::"}],"File":"/home/simonspa/software/nextcloud_server/3rdparty/doctrine/dbal/src/Driver/API/PostgreSQL/ExceptionConverter.php","Line":49,"Previous":{"Exception":"Doctrine\\DBAL\\Driver\\PDO\\Exception","Message":"SQLSTATE[23502]: Not null violation: 7 ERROR:  null value in column \"id\" violates not-null constraint\nDETAIL:  Failing row contains (null, ca16132a23f0963a999cce330076e299, 497680852237d14e545aa365cdaf1bd3, b41a8005b306ebf806a6d2c15ddb5097, f, fraudsters redirected email and web traffic destined for several..., https://krebsonsecurity.com/?p=53649, https://krebsonsecurity.com/2020/11/godaddy-employees-used-in-at..., GoDaddy Employees Used in Attacks on Multiple Cryptocurrency Ser..., BrianKrebs, 1605982549, <p>Fraudsters redirected email and web traffic destined for seve..., null, null, null, null, 54, t, f, 1621765946715399, null, smn).","Code":7,"Trace":[{"file":"/home/simonspa/software/nextcloud_server/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php","line":84,"function":"new","class":"Doctrine\\DBAL\\Driver\\PDO\\Exception","type":"::"},{"file":"/home/simonspa/software/nextcloud_server/3rdparty/doctrine/dbal/src/Connection.php","line":1136,"function":"execute","class":"Doctrine\\DBAL\\Driver\\PDO\\Statement","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/lib/private/DB/Connection.php","line":257,"function":"executeStatement","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":213,"function":"executeStatement","class":"OC\\DB\\Connection","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/lib/private/DB/QueryBuilder/QueryBuilder.php","line":287,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/lib/public/AppFramework/Db/QBMapper.php","line":135,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->"},{"file":"/home/simonspa/software/nextcloud-news/lib/Db/NewsMapperV2.php","line":76,"function":"insert","class":"OCP\\AppFramework\\Db\\QBMapper","type":"->"},{"file":"/home/simonspa/software/nextcloud-news/lib/Service/ItemServiceV2.php","line":110,"function":"insert","class":"OCA\\News\\Db\\NewsMapperV2","type":"->"},{"file":"/home/simonspa/software/nextcloud-news/lib/Service/ShareService.php","line":137,"function":"insertOrUpdate","class":"OCA\\News\\Service\\ItemServiceV2","type":"->"},{"file":"/home/simonspa/software/nextcloud-news/lib/Controller/ItemController.php","line":342,"function":"shareItemWithUser","class":"OCA\\News\\Service\\ShareService","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/lib/private/AppFramework/Http/Dispatcher.php","line":218,"function":"share","class":"OCA\\News\\Controller\\ItemController","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/lib/private/AppFramework/Http/Dispatcher.php","line":127,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/home/simonspa/software/nextcloud_server/lib/base.php","line":993,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/index.php","line":37,"function":"handleRequest","class":"OC","type":"::"}],"File":"/home/simonspa/software/nextcloud_server/3rdparty/doctrine/dbal/src/Driver/PDO/Exception.php","Line":26,"Previous":{"Exception":"PDOException","Message":"SQLSTATE[23502]: Not null violation: 7 ERROR:  null value in column \"id\" violates not-null constraint\nDETAIL:  Failing row contains (null, ca16132a23f0963a999cce330076e299, 497680852237d14e545aa365cdaf1bd3, b41a8005b306ebf806a6d2c15ddb5097, f, fraudsters redirected email and web traffic destined for several..., https://krebsonsecurity.com/?p=53649, https://krebsonsecurity.com/2020/11/godaddy-employees-used-in-at..., GoDaddy Employees Used in Attacks on Multiple Cryptocurrency Ser..., BrianKrebs, 1605982549, <p>Fraudsters redirected email and web traffic destined for seve..., null, null, null, null, 54, t, f, 1621765946715399, null, smn).","Code":"23502","Trace":[{"file":"/home/simonspa/software/nextcloud_server/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php","line":82,"function":"execute","class":"PDOStatement","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/3rdparty/doctrine/dbal/src/Connection.php","line":1136,"function":"execute","class":"Doctrine\\DBAL\\Driver\\PDO\\Statement","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/lib/private/DB/Connection.php","line":257,"function":"executeStatement","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":213,"function":"executeStatement","class":"OC\\DB\\Connection","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/lib/private/DB/QueryBuilder/QueryBuilder.php","line":287,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/lib/public/AppFramework/Db/QBMapper.php","line":135,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->"},{"file":"/home/simonspa/software/nextcloud-news/lib/Db/NewsMapperV2.php","line":76,"function":"insert","class":"OCP\\AppFramework\\Db\\QBMapper","type":"->"},{"file":"/home/simonspa/software/nextcloud-news/lib/Service/ItemServiceV2.php","line":110,"function":"insert","class":"OCA\\News\\Db\\NewsMapperV2","type":"->"},{"file":"/home/simonspa/software/nextcloud-news/lib/Service/ShareService.php","line":137,"function":"insertOrUpdate","class":"OCA\\News\\Service\\ItemServiceV2","type":"->"},{"file":"/home/simonspa/software/nextcloud-news/lib/Controller/ItemController.php","line":342,"function":"shareItemWithUser","class":"OCA\\News\\Service\\ShareService","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/lib/private/AppFramework/Http/Dispatcher.php","line":218,"function":"share","class":"OCA\\News\\Controller\\ItemController","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/lib/private/AppFramework/Http/Dispatcher.php","line":127,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/home/simonspa/software/nextcloud_server/lib/base.php","line":993,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/home/simonspa/software/nextcloud_server/index.php","line":37,"function":"handleRequest","class":"OC","type":"::"}],"File":"/home/simonspa/software/nextcloud_server/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php","Line":82}},"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0","version":"21.0.2.1"}
@simonspa simonspa added the bug label May 23, 2021
@Grotax Grotax added the API Impact API/Backend code label May 23, 2021
@SMillerDev
Copy link
Contributor

Any ideas @mnassabain ?

@mnassabain
Copy link
Contributor

mnassabain commented May 26, 2021

The first thing that comes to my mind is this line.
The shared item is cloned and its id is set to null, allowing the object to be assigned a new id. Maybe PostgreSQL doesn’t like this?

@SMillerDev
Copy link
Contributor

That seems like a reasonable assumption. You'll have to look into how doctorine handles this.

@mnassabain
Copy link
Contributor

Sorry for the late reply, quick update: I think I've managed to solve it, I'll be creating a pull request in the coming days

mnassabain added a commit to mnassabain/news that referenced this issue Jun 12, 2021
This is done to set the id to null BEFORE resetting the updated fields.
The purpose of this is to avoid explicitly adding a NULL id into the DB,
which provokes an error in some DBMS (like postgres).

Fixes nextcloud#1375
mnassabain added a commit to mnassabain/news that referenced this issue Jun 12, 2021
This is done to set the id to null BEFORE resetting the updated fields.
The purpose of this is to avoid explicitly adding a NULL id into the DB,
which provokes an error in some DBMS (like postgres).

Fixes nextcloud#1375

Signed-off-by: Marco Nassabain <[email protected]>
Grotax pushed a commit that referenced this issue Jun 16, 2021
This is done to set the id to null BEFORE resetting the updated fields.
The purpose of this is to avoid explicitly adding a NULL id into the DB,
which provokes an error in some DBMS (like postgres).

Fixes #1375

Signed-off-by: Marco Nassabain <[email protected]>
Neo11 pushed a commit to Neo11/news that referenced this issue May 28, 2022
This is done to set the id to null BEFORE resetting the updated fields.
The purpose of this is to avoid explicitly adding a NULL id into the DB,
which provokes an error in some DBMS (like postgres).

Fixes nextcloud#1375

Signed-off-by: Marco Nassabain <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Impact API/Backend code bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants