Skip to content

[Code review] data-raw/build_uds_crosswalk.R: source("data-raw/helpers.R") is cwd-relative, fragile outside repo root #145

Description

@chris-prener

Parent epic: #129

User story

As a repo maintainer, I want data-raw/build_uds_crosswalk.R to resolve its sourced helper file relative to the script's own location rather than the caller's working directory, so that the build script doesn't silently fail when invoked from outside the repository root.

Problem

data-raw/build_uds_crosswalk.R now does source("data-raw/helpers.R") (added in #143/PR #144 to make bind_rows_base() offline-testable). This path is resolved relative to getwd(), not the script's own location — running the script from any directory other than the repo root fails before the build begins.

This isn't a brand-new constraint: OUT_PATH <- file.path("inst", "extdata", "uds_crosswalk.rds") already assumed cwd == repo root before this change. But the new source() call adds a second, earlier failure point tied to the same assumption, and unlike the save path (which fails gracefully at the end with a clear "file not found" style error), a failed source() fails immediately with a less obvious "cannot open file" error before any download work starts.

Flagged by the institutional code-review gate (rubber-duck pass) on PR #144.

Acceptance criteria

  • data-raw/build_uds_crosswalk.R resolves data-raw/helpers.R (and any future sourced helper) relative to its own script location, or the script fails fast with a clear, actionable error message naming the repo-root requirement.
  • The fix does not require adding a new package dependency (e.g. here) unless that dependency is already justified elsewhere.
  • Manually verified: running the build script from a non-root working directory either works correctly or fails with a clear diagnostic (not a cryptic "cannot open file" error).

Codebase Context

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageAwaiting routing decisionpriority/highSignificant impact, address soontech-debtRefactoring, cleanup, robustness, scaling, or other internal-quality work

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions