#11086·dvc

add: repeated --glob includes generated DVC metadata

Author: tandedeCreated Aug 19, 2026Updated Aug 19, 2026

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

bash
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:

bash
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.