[bug] UploadTomes() function does not properly deduplicate tome names
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 85/100
Research direction
The bug is in tavern/tomes/parse.go at line 95 in the UploadTomes function. Replace entry.Name() with metadata.Name in the duplicate existence check so it uses the parsed tome name instead of the filesystem path. Run the tomes package tests to confirm the fix prevents duplicate entries without errors.
Written by the indexing model from the issue text.
Description
Describe the bug
The UploadTomes function uses the path name to check for duplicates instead of the Metadata.Name()
func UploadTomes(ctx context.Context, graph *ent.Client, fileSystem fs.ReadDirFS) error {
entries, err := fileSystem.ReadDir(".")
...
for _, entry := range entries {
exists, err := graph.Tome.Query().
Where(tome.Name(entry.Name())). // <-- Using path name not metadata.Name()
Exist(ctx)
if exists { // <-- Will always be false
continue
}
...
// Parse metadata
...
// Create the tome
if _, err := graph.Tome.Create().
SetName(metadata.Name) // <-- Causes "ent: constraint failed: UNIQUE constraint failed: tomes.name"
...
}
}
return nil
}
To Reproduce
Call UploadTomes() twice with the same tomes.
Expected behavior
Tome should continue the loop and not error.
- Dominant language
- Rust
- Stars
- 639
- Forks
- 65
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 62
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from spellshift/realm
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
spellshift/realm#2509 ·
Maintainers usually reply within 1 day
-
feature
Difficulty 3/5 1-2 days Newbie friendliness 55/100
spellshift/realm#2461 · 1 comment ·
Maintainers usually reply within 1 day
-
feature
Difficulty 5/5 Over a week Newbie friendliness 15/100
spellshift/realm#2449 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
spellshift/realm#2424 ·
Maintainers usually reply within 1 day
-
feature
Difficulty 5/5 Over a week Newbie friendliness 22/100
spellshift/realm#2357 ·
Maintainers usually reply within 1 day
All issues in spellshift/realm
Similar issues
-
<input type="number"> misses text-entry leaf sizing in layoutPossibly taken @GoCoder7 claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 88/100
DioxusLabs/blitz#1675 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
metasequoiaime/msime#11666 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
bug drawings help wanted ui
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
userFRM/egui-charts#3479 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
s2-streamstore/cachey#225 ·
Maintainers usually reply within 1 day