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

SQL error on creating folders when using PostgreSQL database #508

Open
chris968 opened this issue Mar 14, 2024 · 6 comments
Open

SQL error on creating folders when using PostgreSQL database #508

chris968 opened this issue Mar 14, 2024 · 6 comments
Assignees
Labels

Comments

@chris968
Copy link

Platform info:

  • Passbolt Version: 4.5.2 (CE)
  • Platform and Target:
    -- Operating system: CentOS 7 and official docker image
    -- PHP: 7.4 and 8.2
    -- Web server: nginx
    -- Database server: PostgreSQL 15

How to reproduce:

Create a folder through the web GUI or launching cake passbolt cleanup command.
The web GUI throw an error 500 but the application log show the following entry:

2024-03-14 10:17:03 error: [PDOException] SQLSTATE[23502]: Not null violation: 7 ERROR:  null value in column "id" of relation "folders" violates not-null constraint
DETAIL:  Failing row contains (null, test, 2024-03-14 11:17:03.433147+01, 2024-03-14 11:17:03.433182+01, 0b2ad4a5-c7d1-4c1c-95ef-ede2e477f87a, 0b2ad4a5-c7d1-4c1c-95ef-ede2e477f87a). in /var/www/passbolt/vendor/cakephp/cakephp/src/Database/Statement/StatementDecorator.php on line 180
Request URL: /folders.json?api-version=v2&contain%5Bpermission%5D=1
Client IP: 192.168.122.4

The cake passbolt cleanup command show another error message related to the folders table:

2024-03-14 10:22:09 error: [PDOException] SQLSTATE[42883]: Undefined function: 7 ERROR:  operator does not exist: character = uuid
LINE 1: ..." LEFT JOIN "folders" "Folders" ON "Folders"."id" = "Permiss...
                                                             ^
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts. in /var/www/passbolt/vendor/cakephp/cakephp/src/Database/Statement/StatementDecorator.php on line 180

We reproduce the issue on two distinct setups, the database have been migrated from a working MySQL one.

@stripthis
Copy link
Member

Thanks for the report @chris968, we'll look into it.

@chris968
Copy link
Author

I just realized that this have an impact on creating new passwords.

Screenshot from 2024-03-14 13-46-27

@chris968
Copy link
Author

My current workaround is to disable the "folders" plugin:

<?php

return [
  'passbolt' => [
    'plugins' => [
      'folders' => [
        'enabled' => false,
      ],
    ],
  ],
];
``

@pabloelcolombiano
Copy link
Member

Hi @chris968 ,

it could be that during the migration from MySQL to Postgres, some folders got their id set to null.

  1. Could you run this query in your postgres client, to see if this is the case?
    select * from folders where "id" = null;

  2. Also this query could be interesting:
    select column_name, data_type, character_maximum_length, column_default, is_nullable from INFORMATION_SCHEMA.COLUMNS where table_name = 'folders';

@chris968
Copy link
Author

@pabloelcolombiano of course I can run both commands but we have no folders in our setup:

passbolt-db=>  select * from folders where "id" = null;
 id | name | created | modified | created_by | modified_by
----+------+---------+----------+------------+-------------
(0 rows)

passbolt-db=> select column_name, data_type, character_maximum_length, column_default, is_nullable from INFORMATION_SCHEMA.COLUMNS where table_name = 'folders';
 column_name |        data_type         | character_maximum_length | column_default | is_nullable
-------------+--------------------------+--------------------------+----------------+-------------
 created     | timestamp with time zone |                          |                | NO
 modified    | timestamp with time zone |                          |                | NO
 id          | character                |                       36 |                | NO
 name        | character varying        |                      256 |                | NO
 created_by  | character                |                       36 |                | NO
 modified_by | character                |                       36 |                | NO
(6 rows)

@jsm222
Copy link
Contributor

jsm222 commented Mar 18, 2024

operator does not exist: character = uuid so the folders.id might still be of character type and not of the postgres uuid type @pabloelcolombiano

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

No branches or pull requests

4 participants