@@ -418,6 +418,11 @@ def addProduct(self, product):
418418 # SQLite-backed product in a different directory, we follow
419419 # symlinks, but not when storing the path.
420420 if dbc .engine == 'sqlite' :
421+ if os .path .isabs (dbc .database ):
422+ raise codechecker_api_shared .ttypes .RequestFailed (
423+ codechecker_api_shared .ttypes .ErrorCode .DATABASE ,
424+ "SQLite database must be given by relative path!" )
425+
421426 dbc .database = path_for_fake_root (os .path .join ("/" , dbc .database ),
422427 self .__server .config_directory )
423428
@@ -493,6 +498,16 @@ def addProduct(self, product):
493498 # Connect and create the database schema.
494499 self .__server .add_product (orm_prod , init_db = True )
495500 connection_wrapper = self .__server .get_product (product .endpoint )
501+
502+ if connection_wrapper is None :
503+ err_msg = "Failed to add product."
504+ if dbc .engine == 'sqlite' :
505+ err_msg += " The SQLite database file must be under the " \
506+ "server workspace directory."
507+ raise codechecker_api_shared .ttypes .RequestFailed (
508+ codechecker_api_shared .ttypes .ErrorCode .DATABASE ,
509+ err_msg )
510+
496511 if connection_wrapper .last_connection_failure :
497512 msg = \
498513 f"The configured connection for '/{ product .endpoint } ' " \
@@ -584,6 +599,10 @@ def editProduct(self, product_id, new_config):
584599
585600 old_args = SQLServer .connection_string_to_args (product .connection )
586601 if dbc .engine == 'sqlite' and dbc .database != old_args ['sqlite' ]:
602+ if os .path .isabs (dbc .database ):
603+ raise codechecker_api_shared .ttypes .RequestFailed (
604+ codechecker_api_shared .ttypes .ErrorCode .DATABASE ,
605+ "SQLite database must be given by relative path!" )
587606 dbc .database = path_for_fake_root (
588607 os .path .join ("/" , dbc .database ),
589608 self .__server .config_directory )
@@ -667,6 +686,17 @@ def editProduct(self, product_id, new_config):
667686 LOG .debug ("Product database successfully connected to." )
668687
669688 connection_wrapper = self .__server .get_product (dummy_endpoint )
689+
690+ if connection_wrapper is None :
691+ err_msg = "Failed to edit product."
692+ if dbc .engine == 'sqlite' :
693+ err_msg += " The SQLite database file must be under " \
694+ "the server workspace directory."
695+
696+ raise codechecker_api_shared .ttypes .RequestFailed (
697+ codechecker_api_shared .ttypes .ErrorCode .DATABASE ,
698+ err_msg )
699+
670700 if connection_wrapper .last_connection_failure :
671701 msg = \
672702 f"The configured connection for " \
0 commit comments