Skip to content

Commit

Permalink
fix: allow auto ('0') granularity (#514)
Browse files Browse the repository at this point in the history
Allow 'auto' granularity to be specified as `0`

- Closes #512
  • Loading branch information
jharley authored Jul 29, 2024
1 parent 6b39444 commit 4dbb4e4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion client/v2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (c *Client) retryHTTPCheck(
case http.StatusTooManyRequests:
// TODO: use new retry header timestamps to determine when to retry
return true, nil
case http.StatusBadGateway, http.StatusGatewayTimeout:
case http.StatusBadGateway, http.StatusGatewayTimeout, http.StatusInternalServerError:
return true, nil
default:
return false, nil
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/query_specification_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ func (d *querySpecDataSource) Read(ctx context.Context, req datasource.ReadReque
"granularity can not be greater than time_range/10",
)
}
if *querySpec.Granularity < (*querySpec.TimeRange / 1000) {
if *querySpec.Granularity != 0 && *querySpec.Granularity < (*querySpec.TimeRange/1000) {
resp.Diagnostics.AddAttributeError(
path.Root("granularity"),
"invalid granularity",
Expand Down
5 changes: 4 additions & 1 deletion internal/provider/query_specification_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ func TestAcc_QuerySpecificationDataSource_zerovalue(t *testing.T) {
"value": 0
}
],
"time_range": 7200
"time_range": 7200,
"granularity": 0
}`)
require.NoError(t, err)

Expand All @@ -419,6 +420,8 @@ data "honeycombio_query_specification" "test" {
op = ">"
value = 0
}
granularity = 0
}
output "query_json" {
Expand Down

0 comments on commit 4dbb4e4

Please sign in to comment.