fix(logs): correct timestamp conversion causing 400 Bad Request#16
Merged
Conversation
The `runLogsSearch` function was incorrectly using `time.Unix()` to convert millisecond timestamps returned by `parseTimeString()`. The `time.Unix()` function expects seconds as the first parameter, but was receiving milliseconds, causing it to create timestamps in the year 57063 instead of 2026. This resulted in 400 Bad Request errors from the API. Changes: - Use `time.UnixMilli()` instead of `time.Unix()` in logs_simple.go:658-659 - Add `TestParseTimeString` to validate timestamp parsing returns milliseconds - Verify all other log commands (list, query, aggregate) correctly use string formatting Fixes the error: "failed to search logs: 400 Bad Request (status: 400)" Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The `v2.QueryTimeseriesData` operation is no longer unstable in the Datadog API client library, causing a warning when trying to enable it: "WARNING: 'v2.QueryTimeseriesData' is not an unstable operation" Removed `v2.QueryTimeseriesData` from the unstable operations list in pkg/client/client.go to eliminate the spurious warning. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
📊 Test Coverage ReportThreshold: 80% ❌ Coverage by Package📈 Coverage Status: ❌ FAILED - Coverage below minimum threshold Updated for commit 64446c1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a critical bug in the
pup logs searchcommand that was causing 400 Bad Request errors. The issue was incorrect timestamp conversion from milliseconds to seconds, resulting in dates in the year 57063 instead of 2026.Also removes an obsolete unstable operation warning for
v2.QueryTimeseriesData.Changes
Timestamp Conversion Fix (cmd/logs_simple.go:658-659)
time.Unix(fromTime, 0)totime.UnixMilli(fromTime)time.Unix(toTime, 0)totime.UnixMilli(toTime)parseTimeString()function returns milliseconds, buttime.Unix()expects secondsWarning Fix (pkg/client/client.go:82)
v2.QueryTimeseriesDatafrom unstable operations listTesting (cmd/logs_simple_test.go)
TestParseTimeStringto validate timestamp parsingRoot Cause
When users ran:
The function would:
1738971894000millisecondstime.Unix(1738971894000, 0)treating it as secondsTesting
Related Issues
Fixes user-reported bug:
Error: failed to search logs: 400 Bad Request (status: 400)🤖 Generated with Claude Code