refactor(go.d/dyncfg): split job-name validation per domain#22247
Merged
Conversation
Job-name validation policy is now a Callbacks[C] method so each domain declares its rule explicitly. Two reusable helpers live in the framework: - JobNameRuleStrict (collector — no spaces, dots, colons) - JobNameRuleAllowDots (SD, vnode, secretstore — allows dots in names) Removes the package-level dyncfg.ValidateJobName default that was imposing collector rules on all callers, and lets SD/vnode/secretstore accept dotted identifiers (e.g. FQDNs).
|
stelfrag
approved these changes
Apr 22, 2026
Contributor
There was a problem hiding this comment.
No issues found across 12 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant Client as External API / Netdata Cloud
participant Handler as dyncfg.Handler (Framework)
participant Domain as Callbacks[C] (SD, VNode, Collector)
participant Rules as dyncfg Rules (Validation Helpers)
Note over Client,Rules: Processing "CmdAdd" for Dynamic Configuration
Client->>Handler: CmdAdd(Function fn)
Handler->>Domain: ExtractKey(fn)
Domain-->>Handler: key, job_name, ok
Note over Handler,Domain: NEW: Domain-specific Name Validation
Handler->>Domain: NEW: ValidateJobName(job_name)
alt Domain is Collector
Domain->>Rules: JobNameRuleStrict(job_name)
Rules-->>Domain: error (if dots/spaces/colons)
else Domain is SD / VNode / SecretStore
Domain->>Rules: JobNameRuleAllowDots(job_name)
Rules-->>Domain: error (if spaces/colons)
end
Domain-->>Handler: error status
alt Invalid Name
Handler->>Client: SendCode(400, "invalid job name")
else Valid Name
Handler->>Domain: ParseAndValidate(fn, job_name)
Domain-->>Handler: Config object (C), error
alt Valid Config
Handler->>Domain: Start(C)
Domain-->>Handler: success
Handler->>Client: SendCode(200, "OK")
else Invalid Config
Handler->>Client: SendCode(400, "parse error")
end
end
Note over Handler,Domain: Note: Validation happens before expensive payload parsing.
Merged
Ferroin
pushed a commit
that referenced
this pull request
Apr 27, 2026
(cherry picked from commit 531d549)
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.


Job-name validation policy is now a Callbacks[C] method so each domain declares its rule explicitly. Two reusable helpers live in the framework:
Removes the package-level dyncfg.ValidateJobName default that was imposing collector rules on all callers, and lets SD/vnode/secretstore accept dotted identifiers (e.g. FQDNs).
Summary
Test Plan
Additional Information
For users: How does this change affect me?
Summary by cubic
Split job-name validation by domain in
dyncfg. Collectors keep strict names; service discovery, vnode, and secretstore now accept dotted names (e.g., FQDNs).Refactors
Callbacks[C].ValidateJobName;Handler.CmdAddcalls it before parsing.JobNameRuleStrict(collectors) andJobNameRuleAllowDots(SD, vnode, secretstore).dyncfg.ValidateJobName; update all call sites and tests.Migration
dyncfg.Callbacks, addValidateJobName(name string) errorand use the appropriate helper.Written for commit f6e2874. Summary will update on new commits.