Skip to content

fix(rum): convert relative time strings in sessions commands#39

Merged
platinummonkey merged 1 commit into
mainfrom
fix/rum-sessions-time-conversion
Feb 11, 2026
Merged

fix(rum): convert relative time strings in sessions commands#39
platinummonkey merged 1 commit into
mainfrom
fix/rum-sessions-time-conversion

Conversation

@platinummonkey
Copy link
Copy Markdown
Collaborator

Summary

Fixes issue #37 where pup rum sessions list and pup rum sessions search commands fail with 400 errors when using relative time formats like "1h". The commands were passing raw time strings directly to the Datadog RUM API, which expects date math format ("now-1h"), ISO 8601 timestamps, or Unix milliseconds.

Changes

  • Time conversion (rum.go:665-678, 713-726): Convert relative time strings (e.g., "1h", "30m") to Unix milliseconds using parseTimeString(), matching the behavior of logs commands
  • Early validation (rum.go:665, 713): Validate time parameters before creating API client for faster feedback and better user experience
  • Improved error messages (rum.go:668, 673, 694, 716, 721, 735): Add comprehensive error messages with:
    • Supported format examples (relative, absolute, "now")
    • Request details (parsed timestamps, original input, limit)
    • Troubleshooting tips (time range validity, permissions, data existence)
  • Test coverage (rum_test.go:213-381): Add 8 new test cases across 2 test functions:
    • TestRumSessionsList_TimeConversion: 4 test cases for list command
    • TestRumSessionsSearch_TimeConversion: 4 test cases for search command
    • Tests verify both valid time conversions and invalid time error handling

Test Plan

  • All existing RUM tests pass
  • New time conversion tests pass (8/8 test cases)
  • Full test suite passes with race detection
  • Build succeeds without errors
  • Behavior now matches logs commands (cmd/logs_simple.go)

Before/After

Before:

$ pup rum sessions search --query "@type:view" --from "1h" --limit 3
Error: failed to search RUM sessions: 400 Bad Request (status: 400)

After:

$ pup rum sessions search --query "@type:view" --from "1h" --limit 3
# Works correctly - "1h" is converted to Unix milliseconds

Related Issues

Closes #37


🤖 Generated with Claude Code

Fix bug where `pup rum sessions list` and `pup rum sessions search`
passed raw relative time strings (e.g., "1h") directly to the Datadog
RUM API, causing 400 errors. The RUM API expects either date math
format ("now-1h"), ISO 8601 timestamps, or Unix milliseconds.

Changes:
- Convert relative times to Unix milliseconds using parseTimeString()
- Validate time parameters before creating API client for faster feedback
- Add comprehensive error messages with format hints and troubleshooting
- Include request details in error output for better debugging

Testing:
- Add TestRumSessionsList_TimeConversion with 4 test cases
- Add TestRumSessionsSearch_TimeConversion with 4 test cases
- All tests pass with race detection enabled
- Behavior now matches logs commands (cmd/logs_simple.go:645-653)

Fixes #37

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@platinummonkey platinummonkey requested a review from a team as a code owner February 11, 2026 14:03
@github-actions
Copy link
Copy Markdown

📊 Test Coverage Report

Overall Coverage: 80.4% Coverage

Threshold: 80% ✅

Coverage by Package
## Coverage by Package

- github.com/DataDog/pup/pkg/auth/callback/server.go:40: 81.2%
- github.com/DataDog/pup/pkg/auth/dcr/client.go:28: 100.0%
- github.com/DataDog/pup/pkg/auth/dcr/types.go:24: 100.0%
- github.com/DataDog/pup/pkg/auth/oauth/client.go:22: 100.0%
- github.com/DataDog/pup/pkg/auth/oauth/pkce.go:24: 85.7%
- github.com/DataDog/pup/pkg/auth/storage/factory.go:53: 94.7%
- github.com/DataDog/pup/pkg/auth/storage/keychain.go:44: 42.9%
- github.com/DataDog/pup/pkg/auth/storage/storage.go:58: 71.4%
- github.com/DataDog/pup/pkg/auth/types/types.go:23: 100.0%
- github.com/DataDog/pup/pkg/client/client.go:32: 94.4%
- github.com/DataDog/pup/pkg/config/config.go:22: 100.0%
- github.com/DataDog/pup/pkg/formatter/formatter.go:31: 100.0%
- github.com/DataDog/pup/pkg/useragent/useragent.go:32: 100.0%
- github.com/DataDog/pup/pkg/util/time.go:20: 95.8%

## Summary

total:								(statements)		80.4%

📈 Coverage Status: ✅ PASSED - Coverage meets minimum threshold

Updated for commit ae447c1

@platinummonkey platinummonkey merged commit 7b8f1b4 into main Feb 11, 2026
4 checks passed
@platinummonkey platinummonkey deleted the fix/rum-sessions-time-conversion branch February 11, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] rum sessions: --from relative time not converted, causes 400

1 participant