Loukas Peteinaris Submission - Louk Chatwalker#2
Loukas Peteinaris Submission - Louk Chatwalker#2loukaspe wants to merge 52 commits intoGlobalWebIndex:mainfrom
Conversation
| } | ||
| } | ||
|
|
||
| return err |
There was a problem hiding this comment.
Bug: Incorrect Error Handling for Non-Existent Records
The UpdateMessageFeedback and UpdateChatSessionTitle functions incorrectly treat updates to non-existent records as successful. GORM's Update method returns a nil error with RowsAffected=0 when no rows match the update criteria, rather than gorm.ErrRecordNotFound. This causes the functions to return success (e.g., API 201) for non-existent message or chat session IDs, despite no database changes. RowsAffected should be checked to correctly identify and return a 'not found' error.
Additional Locations (1)
|
|
||
| err = db.AutoMigrate(&repositories.User{}) | ||
| if err != nil { | ||
| log.Fatal("cannot migrate user table") |
There was a problem hiding this comment.
Bug: Startup Data Loss in Production
On startup, the application unconditionally drops the users, messages, and chat_sessions database tables. This results in irreversible data loss in production environments with every service restart. A code comment indicates this behavior was intended for assessment purposes, but it remains active in the main application.
| if err != nil { | ||
| log.Fatalf("Error getting env, not comming through %v", err) | ||
| } | ||
| } |
There was a problem hiding this comment.
Bug: Environment Variable Path Issue
The application fails to start because it attempts to load environment variables from ./config/.env using godotenv.Load. In typical runtime environments (e.g., Docker), the .env file is located at the application root, causing a path mismatch. This results in a fatal error during startup, preventing the server from booting even when required environment variables are already provided.
No description provided.