Repository navigation
Conversation
📝 WalkthroughWalkthrough
ChangesUUID Generation Refactor
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/service/dataset.go`:
- Line 859: The CreateDataset function generates UUIDv4 IDs using
utility.GenerateToken, but downstream functions including ListDatasets,
DeleteDatasets, and GetDataset all validate IDs through normalizeDatasetUUID1,
which explicitly rejects non-v1 UUIDs at Lines 1416-1418. This causes newly
created datasets to fail validation in lookup and delete operations. Either
change the ID generation in CreateDataset to use a UUIDv1-compatible approach
instead of utility.GenerateToken, or refactor the normalization function to
accept both UUID versions and update all callers of normalizeDatasetUUID1 (in
ListDatasets, DeleteDatasets, GetDataset, and any other locations) to use a new
normalization function that handles both UUID v1 and v4 formats.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1c0423e9-978e-43af-b64f-9a86e82dde06
📒 Files selected for processing (4)
internal/service/dataset.gointernal/service/model_service.gointernal/service/user.gointernal/utility/token.go
💤 Files with no reviewable changes (1)
- internal/utility/token.go
| if err != nil { | ||
| return nil, common.CodeServerError, errors.New("Internal server error") | ||
| } | ||
| kbID := utility.GenerateToken() |
There was a problem hiding this comment.
UUID version contract mismatch breaks ID-based dataset flows.
At Line 859, CreateDataset now generates a UUIDv4-based ID, but ListDatasets (Line 580), DeleteDatasets (Line 913), and GetDataset (Line 993) still normalize through normalizeDatasetUUID1, which rejects non-v1 IDs at Lines 1416–1418. New datasets created here can fail lookup/delete paths that validate IDs through that function.
💡 Suggested fix
-func normalizeDatasetUUID1(id string) (string, error) {
+func normalizeDatasetID(id string) (string, error) {
parsedUUID, err := uuid.Parse(id)
if err != nil {
- return "", errors.New("Invalid UUID1 format")
- }
- if parsedUUID.Version() != 1 {
- return "", errors.New("Must be a UUID1 format")
+ return "", errors.New("Invalid UUID format")
}
return strings.ReplaceAll(parsedUUID.String(), "-", ""), nil
}- normalizedID, err := normalizeDatasetUUID1(datasetID)
+ normalizedID, err := normalizeDatasetID(datasetID)(Apply similarly at the other UUID1-only normalization call sites in this file.)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@internal/service/dataset.go` at line 859, The CreateDataset function
generates UUIDv4 IDs using utility.GenerateToken, but downstream functions
including ListDatasets, DeleteDatasets, and GetDataset all validate IDs through
normalizeDatasetUUID1, which explicitly rejects non-v1 UUIDs at Lines 1416-1418.
This causes newly created datasets to fail validation in lookup and delete
operations. Either change the ID generation in CreateDataset to use a
UUIDv1-compatible approach instead of utility.GenerateToken, or refactor the
normalization function to accept both UUID versions and update all callers of
normalizeDatasetUUID1 (in ListDatasets, DeleteDatasets, GetDataset, and any
other locations) to use a new normalization function that handles both UUID v1
and v4 formats.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16010 +/- ##
=======================================
Coverage 93.16% 93.16%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 668 668
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
Refactor: Replaced
utility.GenerateUUID1(UUID v1) withutility.GenerateToken(UUID v4) for generating entity IDs (userID,kbID,modelID, etc.).Cleanup: Removed the unused
GenerateUUID1function fromutilitypackage.Improvement: Simplified ID generation logic and eliminated unnecessary error handling boilerplate since
GenerateTokencannot fail.