Repository navigation
fix(project): validate metric plugin options when saving a project - #9228
Open
chenwei791129 wants to merge 2 commits into
Open
chenwei791129 wants to merge 2 commits into
chenwei791129 wants to merge 2 commits into
Conversation
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
Validate metric plugin options when a project is created or updated, instead of only when a pipeline plan
is generated.
refactor(project): extract the single-metric plan generation ofGeneratePlanJsonV200intomakeMetricPluginPlan. No behavior change; it lets plan generation and save-time validation share thesame rules (e.g. empty options default to
{}).fix(project):CreateProjectandPatchProjectcallvalidateProjectMetricsbefore opening thetransaction or touching the database. It dry-runs
MakeMetricPluginPipelinePlanV200for everyenabled metric, discards the plan, and returns
errors.BadInput(HTTP 400)invalid options for metric plugin <name>wrapping the plugin's error.MakePlanForBlueprint(the Settings page always sends everymetric, with
enable: falsefor disabled ones).MetricPluginBlueprintV200isrejected too, since plan generation would fail on it anyway.
PatchProjectvalidates with the post-save project name (the new name on rename).No Config UI change: the Save button already shows the API error as a toast and the settings are not
stored.
Does this close any open issues?
Closes #9227
Screenshots
N/A — backend only.
Other Information
Compatibility
POST /projects/PATCH /projects/:projectNamenow return 400 instead of 2xx when an enabled metrichas invalid options (e.g. an invalid monorepo
deployJobPattern, or monorepo enabled with nosubProjects). Such requests previously stored settings that broke the next pipeline run.no migration.
Tests
New
backend/server/services/project_metric_validation_test.go:{};BadInputand keeps the original error in the chain;nilmetrics are never invoked;CreateProjectandPatchProjectreject invalid options with a DAL mock that has no expectations,proving nothing is written and no transaction is opened;
PatchProjectuses the new name on renameand the current name otherwise.
go test ./server/services/...plus the dora / linker / issue_trace / monorepo unit tests pass;golangci-lint run ./server/...is clean.