Add durationLiteralOutOfRange to centralise the int64 nanosecond overflow
check for numeric duration literals, replacing three identical inline
conditions in the grammar.
Add applyUnaryOpToDurationExpr to handle the unary +/- type-switch over
*DurationExpr/*NumberLiteral, collapsing two near-identical grammar
action blocks (offset_duration_expr and duration_expr) into single calls.
Regenerate generated_parser.y.go.
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
The `unary_op LEFT_PAREN duration_expr RIGHT_PAREN` production in
`offset_duration_expr` unconditionally asserted `$3.(*DurationExpr)`,
but `duration_expr` can also reduce to a `*NumberLiteral` (e.g. the
literal `0` or `5` inside parentheses). This caused a runtime panic
recoverable only by the top-level recover in parse.go, which surfaced
as an opaque "unexpected error".
Replace the hard type-assertion with a type switch matching the same
pattern used by the `unary_op duration_expr` production in
`duration_expr`: handle `*DurationExpr` (set Wrapped, negate if SUB)
and `*NumberLiteral` (negate value if SUB, range-check, update pos),
with a fallback parse error for unexpected node types.
Regenerate generated_parser.y.go from the updated grammar.
Add regression tests: `foo offset +(5)` and `foo offset -(5)` now
parse correctly as ±5 s offsets.
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
Export ErrUnexpected from the parser package so the fuzz test can use
errors.Is to detect when the parser's recover() handler caught a
runtime panic. Previously these were silently swallowed; now
FuzzParseExpr fails on them.
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
When a MatrixSelector wraps a non-VectorSelector expression (e.g. `1[5m]`),
the grammar records a parse error but continues. The unchecked type assertions
in setAnchored and setSmoothed then panic. Use safe assertions and emit a
parse error instead.
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
Replace the catch-all default branch in encodeToSnapshotRecord and
decodeSeriesFromChunkSnapshot with an explicit EncFloatHistogram case and a
default that panics (encode) or returns an error (decode), making unknown
encodings immediately visible rather than silently mishandling them.
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
EncXOR2 is a float encoding and must be treated like EncXOR in all
places that enumerate chunk types:
- compact.go: NumFloatSamples was not incremented for EncXOR2 chunks
during compaction, leading to under-reported block stats.
- head_wal.go: encodeToSnapshotRecord fell through to the default
(FloatHistogram) branch for EncXOR2 head chunks, which would corrupt
chunk snapshots; the decode path already handled EncXOR2 correctly.
- ooo_head.go: update stale comment to mention EncXOR2.
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
* web/api: reject 0 for limit and batch_size in search endpoints
Treat 0 as invalid for limit and batch_size query parameters; clients
must supply a positive integer or omit the parameter to use the server
default of 100. Update OpenAPI descriptions accordingly.
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
* Update web/api/v1/openapi.go
Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com>
---------
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com>
Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
Add t.Parallel() to the 13 top-level test functions in marathon_test.go.
Tests have no shared mutable state — each test creates its own registry,
metrics, and config — so parallelisation is safe and speeds up the suite.
Refs #15185
Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@hotmail.com>
Each test creates its own httptest.Server and prometheus.Registry so
there is no shared global state between them. Adding t.Parallel() to
all 13 top-level test functions and the subtests in TestUnmarshalConfig
allows the Go test runner to overlap them, cutting wall-clock time.
Refs: #15185
Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@hotmail.com>
Signed-off-by: Kai Tanaka <275430420+quyentonndbs@users.noreply.github.com>
Co-authored-by: Kai Tanaka <275430420+quyentonndbs@users.noreply.github.com>
- Fix copy-paste bug: smoothed branch in bare MatrixSelector eval now
says "smoothed modifier is not supported with histograms" instead of
"anchored".
- Change annosFromInterpolationError to take *annotations.Annotations,
consistent with all other histogram helper functions.
- Rename delta to result in interpolateHistograms to avoid the misleading
name (the variable holds the interpolated result, not a delta).
- Fix extendedRate doc comment: interpolates at boundaries, not
extrapolates.
- Fix stale comment in correctForCounterResetsHistogram that referenced
the nonexistent variable leftInterpolationHandledReset.
- Add comment explaining why right.Copy() is not redundant in
extendedHistogramRate.
- Hoist s.Labels().Get(labels.MetricName) out of the per-step loop in
smoothSeries; was called up to three times per step.
- Reset CounterResetHint to UnknownCounterReset on carry-forward
histograms in smoothSeries; a Reset hint at a new timestamp is
semantically misleading.
- Add TestInterpolateHistograms unit test covering exact-match, midpoint,
counter, reset, and quarter-point cases.
- Add rate(hist_counter[1m] anchored) test.
- Add delta(hist_counter[1m] anchored/smoothed) tests with
NativeHistogramNotGaugeWarning assertions.
- Add carry-forward test for smoothed vector selector.
- Add range eval test for rate(hist_counter[1m] smoothed).
- Add right-boundary reset interpolation test (right_boundary_reset).
- Fix stale test comment about "prev initialPrev path".
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>