Repository navigation
fix(benchmarking): return 404 on missing benchmarks, validate metrics/thresholds, and guard definition auth (closes #911) - #914
Closed
mopxam-art wants to merge 1 commit into
Conversation
…/thresholds, and guard definition auth (closes Heliobond#911)
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.
Overview
Closes #911 by standardizing HTTP 404 responses for missing benchmark resources, validating metrics against the supported set, enforcing non-negative ordering on thresholds, guarding custom definition collisions with built-in benchmarks, and protecting benchmark mutations with admin bearer authentication.
Changes
src/routes/benchmarking.ts:GET /benchmarks/:idandGET /:id/trendto return HTTP 404 (notFound) when a requested benchmark id does not exist.requireAdminBearermiddleware toPOST /benchmarksto ensure consumer API keys cannot mutate global benchmark definitions.metricagainstKNOWN_METRICSwith strict 400 rejection on unknown metrics.poor <= fair <= good <= excellent).idcollisions against built-in benchmarks.src/lib/benchmarking.ts:KNOWN_METRICS,isKnownMetric,isBuiltInBenchmark,getBuiltInBenchmarkIds, andclearCustomBenchmarks.defineCustomBenchmarkto reject built-in ID overwrites.src/middleware/errors.ts: Exported standardnotFound(message)helper returningApiError(404, 'not_found', message).src/__tests__/benchmarking.test.ts: Fixed mislabeled test asserting 400 to assert 404.src/__tests__/benchmarking-5d-matrix.test.ts: Added 111 comprehensive tests across boundaries, combinatorics, parameter variations, negative controls, and lifecycle.Verification
npx jest src/__tests__/benchmarking*).npx tsc --noEmit).