Organisation Api Key: Not working with Postgresql database #1642

Closed
opened 2026-02-05 01:24:10 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @Lowaiz on GitHub (Jul 18, 2023).

Subject of the issue

Organization Api Key endpoints available from Organization's setting are not working.

In src/db/models/organization.rs, the save function of OrganizationApiKey object with the .on_conflict chain call crash.

It seems linked to the behavior and requirements of ON_CONFLICT of Postgre

Deployment environment

Running Vaultwarden wihtin Kubernetes with a Postgresql database

  • Vaultwarden version: v1.29.0
  • Web-vault version: v2023.5.0
  • OS/Arch: linux/x86_64
  • Running within Docker: false (Base: Not applicable)
  • Environment settings overridden: false
  • Uses a reverse proxy: true
  • IP Header check: true (X-Forwarded-For)
  • Internet access: true
  • Internet access via a proxy: false
  • DNS Check: true
  • Browser/Server Time Check: true
  • Server/NTP Time Check: true
  • Domain Configuration Check: true
  • HTTPS Check: true
  • Database type: PostgreSQL
  • Database version: PostgreSQL 11.19 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-12), 64-bit

Steps to reproduce

Run any Vaultwarden instance with a postgresql database

Expected behaviour

Actual behaviour

Troubleshooting data

From log:

[panic][ERROR] thread 'rocket-worker-thread' panicked at 'Error creating organization API Key: Error saving organization.
[CAUSE] DatabaseError(
    Unknown,
    "there is no unique or exclusion constraint matching the ON CONFLICT specification",
)': src/api/core/organizations.rs:2960
   0: vaultwarden::init_logging::{{closure}}
   1: std::panicking::rust_panic_with_hook
   2: std::panicking::begin_panic_handler::{{closure}}
   3: std::sys_common::backtrace::__rust_end_short_backtrace
   4: rust_begin_unwind
   5: core::panicking::panic_fmt
   6: core::result::unwrap_failed
   7: vaultwarden::api::core::organizations::_api_key::{{closure}}
   8: vaultwarden::api::core::organizations::api_key::into_info::monomorphized_function::{{closure}}
   9: rocket::server::<impl rocket::rocket::Rocket<rocket::phase::Orbit>>::route::{{closure}}
  10: rocket::server::hyper_service_fn::{{closure}}::{{closure}}
  11: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
  12: tokio::runtime::task::core::Core<T,S>::poll
  13: tokio::runtime::task::harness::Harness<T,S>::poll
  14: tokio::runtime::scheduler::multi_thread::worker::Context::run_task
  15: tokio::runtime::scheduler::multi_thread::worker::Context::run
  16: tokio::runtime::context::scoped::Scoped<T>::set
  17: tokio::runtime::context::runtime::enter_runtime
  18: tokio::runtime::scheduler::multi_thread::worker::run
  19: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
  20: tokio::runtime::task::core::Core<T,S>::poll
  21: tokio::runtime::task::harness::Harness<T,S>::poll
  22: tokio::runtime::blocking::pool::Inner::run
  23: std::sys_common::backtrace::__rust_begin_short_backtrace
  24: core::ops::function::FnOnce::call_once{{vtable.shim}}
  25: std::sys::unix::thread::Thread::new::thread_start
  26: start_thread
  27: clone
Originally created by @Lowaiz on GitHub (Jul 18, 2023). ### Subject of the issue <!-- Describe your issue here. --> Organization Api Key endpoints available from Organization's setting are not working. In `src/db/models/organization.rs`, the `save` function of OrganizationApiKey object with the [`.on_conflict`](https://github.com/dani-garcia/vaultwarden/blob/3dbfc484a54c41d1759646444b439da06445060b/src/db/models/organization.rs#L808) chain call crash. It seems linked to the behavior and requirements of `ON_CONFLICT` of Postgre ### Deployment environment Running Vaultwarden wihtin Kubernetes with a Postgresql database * Vaultwarden version: v1.29.0 * Web-vault version: v2023.5.0 * OS/Arch: linux/x86_64 * Running within Docker: false (Base: Not applicable) * Environment settings overridden: false * Uses a reverse proxy: true * IP Header check: true (X-Forwarded-For) * Internet access: true * Internet access via a proxy: false * DNS Check: true * Browser/Server Time Check: true * Server/NTP Time Check: true * Domain Configuration Check: true * HTTPS Check: true * Database type: PostgreSQL * Database version: PostgreSQL 11.19 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-12), 64-bit ### Steps to reproduce <!-- Tell us how to reproduce this issue. What parameters did you set (differently from the defaults) and how did you start vaultwarden? --> Run any Vaultwarden instance with a postgresql database ### Expected behaviour <!-- Tell us what you expected to happen --> ### Actual behaviour <!-- Tell us what actually happened --> ### Troubleshooting data <!-- Share any log files, screenshots, or other relevant troubleshooting data --> From log: ``` [panic][ERROR] thread 'rocket-worker-thread' panicked at 'Error creating organization API Key: Error saving organization. [CAUSE] DatabaseError( Unknown, "there is no unique or exclusion constraint matching the ON CONFLICT specification", )': src/api/core/organizations.rs:2960 0: vaultwarden::init_logging::{{closure}} 1: std::panicking::rust_panic_with_hook 2: std::panicking::begin_panic_handler::{{closure}} 3: std::sys_common::backtrace::__rust_end_short_backtrace 4: rust_begin_unwind 5: core::panicking::panic_fmt 6: core::result::unwrap_failed 7: vaultwarden::api::core::organizations::_api_key::{{closure}} 8: vaultwarden::api::core::organizations::api_key::into_info::monomorphized_function::{{closure}} 9: rocket::server::<impl rocket::rocket::Rocket<rocket::phase::Orbit>>::route::{{closure}} 10: rocket::server::hyper_service_fn::{{closure}}::{{closure}} 11: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut 12: tokio::runtime::task::core::Core<T,S>::poll 13: tokio::runtime::task::harness::Harness<T,S>::poll 14: tokio::runtime::scheduler::multi_thread::worker::Context::run_task 15: tokio::runtime::scheduler::multi_thread::worker::Context::run 16: tokio::runtime::context::scoped::Scoped<T>::set 17: tokio::runtime::context::runtime::enter_runtime 18: tokio::runtime::scheduler::multi_thread::worker::run 19: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut 20: tokio::runtime::task::core::Core<T,S>::poll 21: tokio::runtime::task::harness::Harness<T,S>::poll 22: tokio::runtime::blocking::pool::Inner::run 23: std::sys_common::backtrace::__rust_begin_short_backtrace 24: core::ops::function::FnOnce::call_once{{vtable.shim}} 25: std::sys::unix::thread::Thread::new::thread_start 26: start_thread 27: clone ```
Author
Owner

@BlackDex commented on GitHub (Jul 18, 2023):

Already fixed in the current testing tagged images.

@BlackDex commented on GitHub (Jul 18, 2023): Already fixed in the current `testing` tagged images.
Author
Owner

@Lowaiz commented on GitHub (Jul 18, 2023):

OK thx

@Lowaiz commented on GitHub (Jul 18, 2023): OK thx
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/vaultwarden#1642