Skip to content
Closed
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
6 changes: 3 additions & 3 deletions internal/repository/holiday_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import (
"database/sql"
"fmt"
"strconv"

Check failure on line 6 in internal/repository/holiday_repository.go

View workflow job for this annotation

GitHub Actions / test

"strconv" imported and not used

Check failure on line 6 in internal/repository/holiday_repository.go

View workflow job for this annotation

GitHub Actions / lint

"strconv" imported and not used) (typecheck)

Check failure on line 6 in internal/repository/holiday_repository.go

View workflow job for this annotation

GitHub Actions / lint

"strconv" imported and not used) (typecheck)

Check failure on line 6 in internal/repository/holiday_repository.go

View workflow job for this annotation

GitHub Actions / lint

"strconv" imported and not used (typecheck)

Check failure on line 6 in internal/repository/holiday_repository.go

View workflow job for this annotation

GitHub Actions / build

"strconv" imported and not used
"strings"
"time"

Expand Down Expand Up @@ -90,17 +90,17 @@

if filter.Year != nil {
whereConditions = append(whereConditions, "strftime('%Y', date) = ?")
args = append(args, strconv.Itoa(*filter.Year))
args = append(args, fmt.Sprintf("%d", *filter.Year))
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

fmt.Sprintf("%d", *filter.Year) is also likely to trigger staticcheck S1039 (unnecessary Sprintf). Using strconv.Itoa(*filter.Year) avoids the lint issue and would also make the existing strconv import in this file meaningful (right now it’s unused, which will fail the build).

Suggested change
args = append(args, fmt.Sprintf("%d", *filter.Year))
args = append(args, strconv.Itoa(*filter.Year))

Copilot uses AI. Check for mistakes.
}

if filter.Month != nil {
whereConditions = append(whereConditions, "strftime('%m', date) = ?")
args = append(args, strconv.Itoa(*filter.Month))
args = append(args, fmt.Sprintf("%02d", *filter.Month))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WARNING: Repository expects month in "%02d" format (e.g., "01", "02"), but the handler sends month as integer (1, 2) to the repository. This will cause month filtering to silently fail.

}

if filter.Day != nil {
whereConditions = append(whereConditions, "strftime('%d', date) = ?")
args = append(args, strconv.Itoa(*filter.Day))
args = append(args, fmt.Sprintf("%02d", *filter.Day))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WARNING: Same issue as line 98 - day filter expects "%02d" format but receives integer.

}

if filter.Type != nil {
Expand Down
5 changes: 2 additions & 3 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"encoding/json"
"fmt"
"net/http"
"strconv"
"time"
)

Expand Down Expand Up @@ -102,10 +101,10 @@ func (c *Client) GetHolidays(ctx context.Context, year, month *int, holidayType

q := req.URL.Query()
if year != nil {
q.Add("year", strconv.Itoa(*year))
q.Add("year", fmt.Sprintf("%d", *year))
}
if month != nil {
q.Add("month", strconv.Itoa(*month))
q.Add("month", fmt.Sprintf("%d", *month))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CRITICAL: Month filtering will break - the API handler parses month as integer (1-12), but this sends zero-padded string (01-12). When user passes month=1, this sends "01" which fails the integer parsing in the handler (strconv.Atoi("01") returns 1, but the filter won't match the "01" in SQL).

Comment on lines 103 to +107
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

fmt.Sprintf("%d", ...) on query parameters will be flagged by staticcheck (S1039) as unnecessary formatting. Since there’s no zero-padding needed here, prefer strconv.Itoa(...) (and re-add the strconv import) to keep golangci-lint green.

Copilot uses AI. Check for mistakes.
}
if holidayType != "" {
q.Add("type", holidayType)
Expand Down
Loading