Bug Report
Description
Running the same dvc add --glob command twice fails when the pattern also matches the .dvc files created by the first run. The first run tracks the data successfully; the second expands both the original data paths and their generated stage files, then tries to add a stage file as data.
Reproduce
git init -q repo
cd repo
dvc init -q
mkdir data
printf "one\n" > data/one
printf "two\n" > data/two
dvc add --glob "data/*"
dvc add --glob "data/*"
The second command exits with status 1:
ERROR: DVC file 'one.dvc' cannot be an output.
This also prevents the common update workflow where new files are added to the directory and the same glob command is rerun to update existing matches and add the new ones.
Expected
Wildcard expansion for dvc add --glob should ignore DVC metadata (*.dvc, dvc.yaml, and dvc.lock) because those paths cannot be DVC outputs. Explicitly passing a metadata path should remain invalid and retain the existing error.
Analysis
dvc.repo.add.find_targets() currently passes every filesystem glob match to get_or_create_stage(). On the second invocation, generated stage files are therefore treated as new output targets and rejected by output-path validation.
Environment
DVC main at 56e59829, Python 3.13, macOS arm64.
Bug Report
Description
Running the same
dvc add --globcommand twice fails when the pattern also matches the.dvcfiles created by the first run. The first run tracks the data successfully; the second expands both the original data paths and their generated stage files, then tries to add a stage file as data.Reproduce
The second command exits with status 1:
ERROR: DVC file 'one.dvc' cannot be an output.This also prevents the common update workflow where new files are added to the directory and the same glob command is rerun to update existing matches and add the new ones.
Expected
Wildcard expansion for
dvc add --globshould ignore DVC metadata (*.dvc,dvc.yaml, anddvc.lock) because those paths cannot be DVC outputs. Explicitly passing a metadata path should remain invalid and retain the existing error.Analysis
dvc.repo.add.find_targets()currently passes every filesystem glob match toget_or_create_stage(). On the second invocation, generated stage files are therefore treated as new output targets and rejected by output-path validation.Environment
DVC
mainat56e59829, Python 3.13, macOS arm64.