[Bug][Project] Invalid metric plugin options are accepted on project save and only fail at the next pipeline run
Maintainer antworten meist innerhalb von 2 Tagen
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- Ein halber Tag
- Anfängerfreundlichkeit
- 22/100
Rechercherichtung
Start in backend/server/services/project.go at refreshProjectMetrics, which CreateProject and PatchProject call without validating pluginOption. Then read the MakeMetricPluginPipelinePlanV200 implementations in the monorepo and dora plugins, which already compile the regex. Done means an invalid regex or empty sub-project list returns HTTP 400 without writing to the database, while valid Go-only syntax such as (?i) is still accepted. Pull request #9228 is already open against this issue, so check it before starting.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Search before asking
- I had searched in the issues and found no similar issues.
What happened
Some metric plugin settings on the Config UI Project → Settings page take a regex, e.g. the
Deploy job pattern of Monorepo Sub-Projects.
If the regex is invalid (e.g. ^deploy-(a, missing a closing parenthesis), clicking Save reports
success and the setting is stored. The error only surfaces the next time a pipeline plan is generated
(Collect Data or the scheduled run):
- The whole blueprint fails to start, not just that metric — data collection from every data source
stops as well. - The error is reported on the pipeline / blueprint, far from the Settings page where the mistake was
made, so it is hard to connect the two. - With a scheduled blueprint, it can take hours before anyone notices the data stopped updating.
The same happens when Monorepo Sub-Projects is enabled with no sub-projects at all.
Project Settings → Save Collect Data / cron (hours later)
│ │
▼ ▼
PATCH /projects/:projectName MakePlanForBlueprint
│ │
▼ ▼
refreshProjectMetrics MakeMetricPluginPipelinePlanV200
stores pluginOption as-is ──── DB ────► compiles `^deploy-(a` ✗ error
│ │
▼ ▼
2xx ✓ "saved" whole blueprint fails,
no data collected at all
Root cause:
POST /projectsandPATCH /projects/:projectNamestore each metric'spluginOptionas-is via
refreshProjectMetrics(backend/server/services/project.go), without any validation.- The actual validation lives in each metric plugin's
MakeMetricPluginPipelinePlanV200(monorepo
rejects an emptysubProjectslist and compiles everydeployJobPattern, returningBadInput), which
is only called when a pipeline plan is generated — i.e. when a blueprint is saved or triggered. - The monorepo code comment says "Validate eagerly so a bad regex is reported when the blueprint is
saved", but editing metric settings from Project Settings never goes through the blueprint save
flow, so this path is never validated.
What do you expect to happen
Invalid metric plugin options should be rejected when the project is saved:
- Saving with an invalid regex shows an error, and the previous settings remain unchanged.
- Saving with a valid regex (including Go-only syntax such as
(?i)) succeeds. - Disabled metrics carrying invalid options do not block saving (they are not used for plan generation
either). - Creating a project (
POST /projects) is validated the same way.
Proposed fix: before writing to the database, CreateProject / PatchProject dry-run
MakeMetricPluginPipelinePlanV200(projectName, pluginOption) for every enabled metric, discard the
generated plan, and reject the request with HTTP 400 (BadInput) as invalid options for metric plugin <name>,
wrapping the plugin's own error (e.g. subProjects[0] (serviceA): invalid deployJobPattern caused by
error parsing regexp: missing closing ): `^deploy-(a` ).
- Every current metric plugin (dora, linker, issue_trace, monorepo) only parses JSON and builds a plan
inMakeMetricPluginPipelinePlanV200— no database access or other side effects — so it is safe to
reuse as a validator. - Some plugins return
errors.Default(500) on a JSON unmarshal failure; wrapping withBadInput
makes it a 400 instead of a server error. - No Config UI change is needed: the Save button already shows the API error message as a toast.
- Any metric plugin that validates its options in
MakeMetricPluginPipelinePlanV200automatically
gets save-time validation, with no further server change.
Out of scope:
- Client-side regex validation: JavaScript
RegExpdiffers from Go RE2 (e.g. no(?i)) and would
reject valid patterns. - The linker
prToIssueRegexp: it is only compiled at task runtime, not in
MakeMetricPluginPipelinePlanV200, so this fix does not cover it. Could be a follow-up. - A dedicated plugin validation interface (e.g.
ValidateMetricPluginOption): cleaner semantically,
but requires acore/plugininterface change.
How to reproduce
- Create a project and enable Monorepo Sub-Projects on the Settings tab.
- Add a sub-project with Deploy job pattern
^deploy-(aand click Save — it reports success. - Go to the Blueprint tab and click Collect Data — plan generation fails and no pipeline runs, so
no data is collected at all.
Anything else
Happens every time an enabled metric has invalid options.
Version
main (4ad2f66df042386888cbcd7a0b585c4a2c13f90a)
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
- Vorherrschende Sprache
- Go
- Sterne
- 3.2k
- Forks
- 819
- Ø Merge
- 2 T. 22 Std.
- Gemergte PRs (30 T.)
- 43
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Kein Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus apache/devlake
-
[Bug][Dashboard] Engineering Throughput PR time panels count PRs without a project_pr_metrics row as 0 hoursEvtl. vergeben @chenwei791129 hat das vor 1 Tag übernommen. Offen
Schwierigkeit 3/5 Ein halber Tag Anfängerfreundlichkeit 22/100
Maintainer antworten meist innerhalb von 2 Tagen
-
[Bug][e2e] Several plugin e2e tests fail on a fresh database because they depend on tables created by other testsEvtl. vergeben @chenwei791129 hat das vor 1 Tag übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
Maintainer antworten meist innerhalb von 2 Tagen
-
[Feature][dora] Allow filtering which pull requests count toward Lead Time for Changes by branch nameEvtl. vergeben @chenwei791129 hat das vor 1 Tag übernommen. Offen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 15/100
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 3/5 Ein halber Tag Anfängerfreundlichkeit 62/100
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 42/100
Maintainer antworten meist innerhalb von 2 Tagen
Ähnliche Issues
-
documentation hacktoberfest priority: low skill: good first issue status: ready for dev
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 85/100
hyperledger-labs/fabric-smart-client#2142 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
numberly/vault-db-injector#107 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area/import kind/bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
Maintainer antworten meist innerhalb von 1 Tag
-
[DOC] Wrong sg_egress_ports range in the Terraform Databricks Guide for AWS Hub & Spoke with Network FirewallEvtl. vergeben @akhil9tiet hat das heute übernommen. Offendocs
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
databricks/terraform-provider-databricks#6080 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 3 Tagen
-
spqr-coordinator usage shows 'run --config', but 'run' is not a subcommand (unknown command "run")Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
pg-sharding/spqr#3092 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag