fix: add allowlist validation for RAG pipeline names#337
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughA compiled regex allowlist ( Changes
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Duplication | 0 |
TIP This summary will be updated as you push new changes. Give us feedback
There was a problem hiding this comment.
🧹 Nitpick comments (1)
server/internal/database/rag_service_config.go (1)
13-17: Single-source the regex text to avoid drift between validation and error output.The pattern is currently duplicated in
MustCompile(...)and in the error string. If one changes later, tests/messages can silently diverge.♻️ Proposed refactor
+const ragPipelineNamePatternText = `^[a-z0-9_-]+$` -var ragPipelineNamePattern = regexp.MustCompile(`^[a-z0-9_-]+$`) +var ragPipelineNamePattern = regexp.MustCompile(ragPipelineNamePatternText) ... - errs = append(errs, fmt.Errorf("%s.name %q is invalid: must match ^[a-z0-9_-]+$", prefix, p.Name)) + errs = append(errs, fmt.Errorf("%s.name %q is invalid: must match %s", prefix, p.Name, ragPipelineNamePatternText))Also applies to: 138-140
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@server/internal/database/rag_service_config.go` around lines 13 - 17, The regex text is duplicated; extract the pattern string into a single const (e.g., ragPipelineNamePatternText) and use that constant when creating ragPipelineNamePattern with regexp.MustCompile(ragPipelineNamePatternText) and when building any validation error messages so they remain in sync (also update the other duplicated occurrences that reference the same literal around the rag pipeline validation). Ensure you reference ragPipelineNamePatternText in all places instead of retyping the literal.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@server/internal/database/rag_service_config.go`:
- Around line 13-17: The regex text is duplicated; extract the pattern string
into a single const (e.g., ragPipelineNamePatternText) and use that constant
when creating ragPipelineNamePattern with
regexp.MustCompile(ragPipelineNamePatternText) and when building any validation
error messages so they remain in sync (also update the other duplicated
occurrences that reference the same literal around the rag pipeline validation).
Ensure you reference ragPipelineNamePatternText in all places instead of
retyping the literal.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 47336a12-65a1-4da9-a25c-d2e9cab89f4a
📒 Files selected for processing (2)
server/internal/database/rag_service_config.goserver/internal/database/rag_service_config_test.go
jason-lynch
left a comment
There was a problem hiding this comment.
Nice! I do have one suggestion, but it's non-blocking if you're certain that these filenames won't be used as a command line argument.
Summary
This PR adds allowlist validation for RAG pipeline names, rejecting names that don't match
^[a-z0-9_-]+$at the API layer before any resources are provisioned.Changes
ragPipelineNamePatternregex (^[a-z0-9_-]+$) toserver/internal/database/rag_service_config.govalidateRAGPipeline, producing a clear error message on rejectionTestParseRAGServiceConfig_PipelineNameAllowlistcovering 7 valid and 7 invalid name variants (spaces, uppercase, slashes, path traversal, dots, Unicode)Testing
Checklist
PLAT-536