Skip to content

Live dbg! in privacy.rs writes to stderr in released builds when private_constants is configured #49

Description

@iMacTia

Found by @dduugg while reviewing #45. Pre-existing and unrelated to that PR.

src/packs/checker/privacy.rs:64 has a live dbg! that writes to stderr on every privacy check for a pack configured with private_constants, including in released builds:

dbg!(constant_is_private, constant_is_in_private_namespace);

Repro

A minimal app with private_constants on the defining pack:

packwerk.yml            cache: false
packs/foo/package.yml   enforce_privacy: true
packs/bar/package.yml   enforce_privacy: true
                        private_constants:
                          - "::Bar"

with packs/foo/app/services/foo.rb referencing Bar:

$ pks --project-root . check 2>stderr.txt
$ cat stderr.txt
[src/packs/checker/privacy.rs:64:13] constant_is_private = true
[src/packs/checker/privacy.rs:64:13] constant_is_in_private_namespace = false

It fires once per checked reference, so on a large tree using private_constants it is a lot of stderr noise, and it leaks internal file and line numbers into user-facing output.

Why it survived

No fixture in tests/fixtures/ configures private_constants, so nothing in the suite exercises this branch. grep -rl private_constants tests/fixtures/ returns nothing, against three hits under src/. Worth a fixture alongside the removal, since the surrounding logic (constant_is_private versus constant_is_in_private_namespace) is currently untested too.

Fix

Delete the line. Happy to send a PR with a fixture that covers the branch if that would be useful.

Sent with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions