rust-lang/rust · error · InvalidCheck
Duplicated file `{}` in {}
Error message
Duplicated file `{}` in {} What it means
Raised as InvalidCheck by check_files_in_folder() when the same filename appears more than once in the bracketed list of a 'files' directive. The check builds a set and rejects duplicates before comparing against the directory contents, because a duplicate would otherwise cancel out a real missing/extra entry in the set arithmetic.
Source
Thrown at src/etc/htmldocck.py:488
cache.get_tree(c.args[0]), pat, c.args[2], regexp, stop_at_first
)
def check_files_in_folder(c, cache, folder, files):
files = files.strip()
if not files.startswith("[") or not files.endswith("]"):
raise InvalidCheck(
"Expected list as second argument of {} (ie '[]')".format(c.cmd)
)
folder = cache.get_absolute_path(folder)
# First we create a set of files to check if there are duplicates.
files = shlex.split(files[1:-1].replace(",", ""))
files_set = set()
for file in files:
if file in files_set:
raise InvalidCheck("Duplicated file `{}` in {}".format(file, c.cmd))
files_set.add(file)
folder_set = set([f for f in os.listdir(folder) if f != "." and f != ".."])
# Then we remove entries from both sets (we clone `folder_set` so we can iterate it while
# removing its elements).
for entry in set(folder_set):
if entry in files_set:
files_set.remove(entry)
folder_set.remove(entry)
error = 0
if len(files_set) != 0:
print_err(
c.lineno,
c.context,
"Entries not found in folder `{}`: `{}`".format(folder, files_set),
)
error += 1View on GitHub (pinned to 7088e4b63a)
Solutions
- Remove the duplicate entry from the bracketed list so each filename appears once.
- Re-run the test to confirm the directive parses.
Example fix
// before //@ files: mydir [a.html a.html b.html] // after //@ files: mydir [a.html b.html]
Defensive patterns
Strategy: validation
Validate before calling
def no_duplicate_files(files_str: str) -> bool:
import shlex
inner = files_str.strip()[1:-1].replace(",", "")
entries = shlex.split(inner)
return len(entries) == len(set(entries))
if not no_duplicate_files(files_arg):
raise SystemExit(f"files directive contains duplicate entries: {files_arg!r}") Type guard
def has_unique_entries(files_str: str) -> bool:
import shlex
inner = files_str.strip()[1:-1].replace(",", "")
entries = shlex.split(inner)
return len(entries) == len(set(entries)) Try / catch
from srcetc_htmldocck import InvalidCheck
try:
check_files_in_folder(c, cache, folder, files)
except InvalidCheck as e:
if "Duplicated file" in str(e):
logging.error("de-duplicate the files list before re-running")
raise Prevention
- De-duplicate file lists when editing files directives.
- Add a lint rule that rejects repeated entries inside the brackets.
- Generate files lists programmatically rather than hand-editing to avoid copy-paste dupes.
When it happens
Trigger: Authoring `//@ files: mydir [a.html a.html b.html]` (a.html listed twice). The loop at htmldocck.py:486-489 detects the repeat.
Common situations: Copy-paste error when editing a file list; merging two lists without de-duplicating; refactoring a directive and forgetting to remove the old entry.
Related errors
- Expected list as second argument of {} (ie '[]')
- line {}: {}
- Non-absolute XPath is not supported due to implementation is
- Tried to use the previous path in the first command
- glob path does not resolve to one file
AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10).
Data as JSON: /api/errors/7a910eaca8303b26.
Report an issue: GitHub.