In DVC, CI's `dvc pull` succeeds for the project's own S3 remote but fails on a directory added with `dvc import` — why, and how do you fix it without committing secrets?
answer
- imported bytes never reach your remote
- the source repository's default remote
- the source's private config stays behind
- --remote and --remote-config
- --config with a Git-ignored file
basics
~20 sdvc push skips data from dvc import, so dvc pull fetches it from the source repository's default remote, which CI may not reach. Select a reachable source remote with --remote and pass secrets via --config with a Git-ignored file.
solid answer
~40 sAn import `.dvc` file records the source `url` and `rev_lock`, and `dvc push` skips repository imports, so on `dvc pull` DVC opens the source repository at that commit and downloads from its default remote. Here that default is the office NAS over `ssh://`, which CI cannot reach, and the source team's `.dvc/config.local` never travels. Fixes: re-import with `--remote <name>` to choose another remote the source repository defines, such as its S3 one; give CI credentials through environment variables or a profile; pass non-secret settings such as `profile=lidar-ci` with `--remote-config`, which is written into the tracked `.dvc` file; and pass secrets with `--config <file>`, which records only the path of a Git-ignored config file that CI materialises from its secret store.
code
bash · 9 lines[email protected]:robotics/lidar-data.git
# choose the source's S3 remote and a non-secret profile; both are recorded in the .dvc file
dvc import "$SRC" lidar-scans/aisle-07 -o data/aisle-07 --rev v2.1 \
--remote s3-archive --remote-config profile=lidar-ci
# alternative for secrets: only the path ci-dvc.conf is recorded, the file is Git-ignored
echo "/ci-dvc.conf" >> .gitignore
# dvc import "$SRC" lidar-scans/aisle-07 -o data/aisle-07 --rev v2.1 --config ci-dvc.confgo deeper
Recall that dvc import keeps a link to another repository and that its data is pulled from that repository's storage, not from your own remote.
Explain what the import .dvc file's repo section records, and how --remote, --remote-config and --config steer the source repository's remote.
Diagnose a CI pull that fails only on imports, fix it without committing a secret, and test pulls from a clean clone with CI's credentials alone.
Decide whether shared datasets are consumed by import from a central repository or copied into each project, given who must hold access to whose storage.
## Where imported bytes come from `dvc import <repo> <path>` creates an import `.dvc` file. Its dependency has a `repo` section with the source `url`, an optional `rev` and the resolved `rev_lock` commit. Two rules decide what happens later: - `dvc push` **skips repository imports**. The consuming project's remote never receives those objects. - `dvc pull` therefore downloads them **from the source**: DVC opens the source repository at `rev_lock`, reads its committed configuration, and fetches from that repository's default remote. A local source repository is the exception, where DVC tries its cache first. Data from `dvc import-url` is different: it is cached like an ordinary output and can be pushed to and pulled from your own remote. ## Why CI's credentials do not reach it The consuming project's CI holds credentials for `s3://example-lidar-scans/dvc`, its own remote. The imported `aisle-07` directory comes from the robotics repository, whose `core.remote` is the office NAS at `ssh://[email protected]/volume1/dvc-store`. Three things can break: 1. The source's default remote is not reachable from CI at all, as an office NAS often is not. 2. It is reachable but needs different credentials, such as another bucket or account. 3. The source team keeps its credentials in its own `.dvc/config.local`, which is Git-ignored and so never travels with the repository. `dvc pull -v` shows which URL it tried, and `dvc get --show-url <repo> <path>` prints the storage location of the target without downloading it. ## Steering the source repository's remote `dvc import` (like `dvc get` and `dvc list`) accepts options that apply to the **source** repository, and `dvc import` records them in the import `.dvc` file so later pulls and updates use them: | Option | What it does | What the `.dvc` file records | |---|---|---| | `--remote <name>` | sets which of the source's remotes is the default | `remote: <name>` under `repo` | | `--remote-config k=v ...` | merges options into the source's default remote, or into the one named by `--remote` | the pairs under `repo.remote`; combined with `--remote`, a `config` block holding both | | `--config <path>` | merges a config file into the source's configuration | only the file path, as `repo.config` | The consequence is the security point: anything passed with `--remote-config` lands in a file Git tracks. `--remote-config profile=lidar-ci` is fine because a profile name is not a secret. `--remote-config secret_access_key=...` publishes the key in the next commit. For secrets, DVC's docs show `--config` with a Git-ignored file in `dvc config` format; the `.dvc` file then records only the path, and every machine that pulls has to have that file. With `--remote-config profile=lidar-ci` alone, the dependency ends up like this, and the whole block is committed: ```yaml deps: - path: lidar-scans/aisle-07 repo: url: [email protected]:robotics/lidar-data.git rev_lock: 9c1e4f... remote: profile: lidar-ci ``` Replace `profile: lidar-ci` with a key pair and the leak is plain to see, which is the reason to read every import `.dvc` file before committing it. ## Fixing the CI failure 1. **Choose a reachable source remote.** If the robotics repository also defines an S3 remote that holds the data, re-import with `--remote` naming it. 2. **Supply credentials CI already knows how to use.** For an S3 source, environment variables or a named profile work without writing anything secret; `--remote-config profile=...` can select the profile. 3. **For secrets that must be in DVC config,** use `--config ci-dvc.conf`, add that file to `.gitignore`, and have the CI job write it from its secret store before `dvc pull`. 4. **If the consuming team should own its copy,** `dvc get` the directory and `dvc add` it, which makes it an ordinary output that `dvc push` uploads, at the cost of losing the link that `dvc update` follows. ## Checks before you rely on an import - Read the import `.dvc` file and confirm `rev_lock` and the `repo` section say what you expect. - Confirm the source's default remote actually holds the data; `dvc list` does not check that. - Run the CI job's `dvc pull` against a fresh clone with only CI's credentials, which is the case a laptop with every credential never tests.
- What does `--remote-config profile=lidar-ci` leave in the import `.dvc` file?A `remote` entry under the dependency's `repo` section containing `profile: lidar-ci`. The file is committed, so every consumer's pull uses that profile name. That is safe for a profile name and unsafe for a key, which is why secrets go through `--config` with a Git-ignored file.
- Why not just `dvc push` the imported directory to your own S3 remote so CI needs one set of credentials?`dvc push` skips repository imports by design; the import stays tied to its source. To own a copy, `dvc get` the directory and `dvc add` it as an ordinary output, which `dvc push` then uploads. You lose the link that `dvc update` follows.
- How do you see which storage location an import will read from before CI fails on it?`dvc get --show-url <repo> <path>` prints the storage URL of the target without downloading it. `dvc pull -v` in a clean clone with only CI's credentials shows the same thing as the failure would.
- dvc push uploads imported directories to the project's own remote
- The source repository's .dvc/config.local travels with the import
- --remote-config values are used once and never written to disk
- dvc import copies the imported data into the consuming repo's Git history
- --config stores the config file's contents inside the .dvc file