Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ jobs:
cache: 'maven'

- name: Build with Maven
run: mvn -B --no-transfer-progress clean test
run: mvn -B --no-transfer-progress clean test
env:
TEST: TRUE
8 changes: 6 additions & 2 deletions src/main/java/backend/ConnectionProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@
* It creates one centralized EntityManagerFactory that can be used in the whole program
*/
public class ConnectionProvider {
private static final Dotenv env = Dotenv.configure().load();
private static final Dotenv env = Dotenv.configure()
.ignoreIfMissing()
.load();
private static final PersistenceConfiguration cfg;
private static final EntityManagerFactory EMF;

private static boolean testing = false;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Root cause of pipeline failure: testing flag is hardcoded and ignores the TEST environment variable.

The CI workflow sets TEST=TRUE, but this flag is hardcoded to false. The code never reads the environment variable, so the production configuration branch is always taken—even in CI—where env.get("PASSWORD") returns null (since no .env file exists), causing the NullPointerException.

Proposed fix: read from environment variable
-    private static boolean testing = false;
+    private static final boolean testing = "TRUE".equalsIgnoreCase(System.getenv("TEST"));

Using System.getenv("TEST") directly (rather than env.get("TEST")) ensures the CI-provided environment variable is read even when no .env file exists. The equalsIgnoreCase with the literal first avoids NPE when TEST is unset.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private static boolean testing = false;
private static final boolean testing = "TRUE".equalsIgnoreCase(System.getenv("TEST"));
🤖 Prompt for AI Agents
In `@src/main/java/backend/ConnectionProvider.java` at line 21, The static boolean
testing in ConnectionProvider is hardcoded to false and ignores the CI-provided
TEST env var; change the initialization to read System.getenv("TEST") (e.g., set
testing = "TRUE".equalsIgnoreCase(System.getenv("TEST"))) so the CI value is
respected and avoid NPEs by calling equalsIgnoreCase on the literal; update any
logic in ConnectionProvider that relies on env.get("TEST") to use the new
testing variable.


static{
try{
if(env.get("TEST").equals("TRUE")){
if (testing){

cfg = new HibernatePersistenceConfiguration("persistence")
.jdbcUrl("jdbc:mysql://localhost:3307/testdb")
Expand Down
Loading