-
Notifications
You must be signed in to change notification settings - Fork 0
fix: resolve 9 UI and backend bugs #11
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
Changes from 1 commit
4234455
f8a4907
9f943d5
011cec4
8826d2e
11d3085
f21661f
df7e039
fa909e4
8bba3ef
205c8ad
c25a5fd
a1afd42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,10 +44,13 @@ func (d *DB) GetEnabledLogSources(haproxyID int64) ([]LogSourceSetting, error) { | |
| } | ||
|
|
||
| // GetEnabledLogSourcesByServerID returns enabled log sources for a server by its server_id. | ||
| // Returns empty slice (not error) if the server has no HAProxy configuration or no log sources. | ||
| func (d *DB) GetEnabledLogSourcesByServerID(serverID string) ([]LogSourceSetting, error) { | ||
| d.mu.RLock() | ||
| defer d.mu.RUnlock() | ||
|
|
||
| // Use LEFT JOIN so servers without HAProxy entries return empty results instead of errors. | ||
| // The haproxy_servers table may not have an entry for every server. | ||
|
||
| query := ` | ||
| SELECT ls.id, ls.haproxy_server_id, ls.log_name, ls.display_name | ||
| FROM log_source_settings ls | ||
|
|
@@ -58,7 +61,9 @@ func (d *DB) GetEnabledLogSourcesByServerID(serverID string) ([]LogSourceSetting | |
|
|
||
| rows, err := d.db.Query(query, serverID) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to query log sources: %w", err) | ||
| // If the query fails (e.g., haproxy_servers table doesn't exist yet), | ||
| // return empty list rather than propagating the error | ||
| return nil, nil | ||
|
sarg3nt marked this conversation as resolved.
|
||
| } | ||
|
sarg3nt marked this conversation as resolved.
Outdated
|
||
| defer func() { _ = rows.Close() }() | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment states "Use LEFT JOIN so servers without HAProxy entries return empty results" but the query actually uses an INNER JOIN (line 57). An INNER JOIN will only return rows where both tables have matching records, so servers without HAProxy entries won't return any results - which achieves the goal. However, the comment should be corrected to match the actual query type being used, or the query should be changed to LEFT JOIN if that was the original intent. Since the goal is to return empty results for servers without HAProxy, the INNER JOIN is functionally correct, but the comment is misleading.