Skip to content

merge queue: checking #1843 on main (7fe8e67) - #1853

Closed
mergify[bot] wants to merge 4 commits into
mainfrom
mergify/merge-queue/bb3dadc6e0
Closed

mergify[bot] wants to merge 4 commits into
mainfrom
mergify/merge-queue/bb3dadc6e0

Conversation

@mergify

@mergify mergify Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request has been checked successfully and will be merged soon. 🎉

#1843 is queued for merge on branch main (7fe8e67).

This pull request has been created by Mergify to check the mergeability of #1843.
You don't need to do anything. Mergify will close this pull request automatically when it is complete.

Required conditions of queue rule default for merge:

Required conditions to stay in the queue:

---
checking_base_sha: 7fe8e672fd6dd81bdaf5b39294b88af8fd95b0a3
previous_check_retries: []
previous_failed_batches: []
pull_requests:
  - number: 1843
    scopes: []
scopes: []
...

sileht and others added 4 commits September 21, 2026 07:13
…e environment

The two tests that pinned "clap must not read `MERGIFY_*` itself"
each exported one variable empty and parsed one argv. They were the
last two `temp_env` calls in `mergify-cli`, and the only ones whose
reader was a dependency rather than our own code.

They are two tests now, at the two altitudes the rule lives at. A
walk over the built `clap::Command` tree asserts that no argument
anywhere declares `env = "…"`, which catches the hook at declaration
and covers every argument rather than `--config` and
`--test-exit-code`. A parse of each of those two argvs asserts the
observable property the deleted tests asserted, because the walk
only sees that one spelling: `default_value_t =
std::env::var(…).unwrap_or_default()` reproduces monorepo#33423
exactly and declares no hook. Neither test needs an environment.

`MERGIFY_BASE_URL` joins the rest in treating exported-but-empty as
unset. `install.sh` already guards the same lever with `[ -n … ]`, so
the two halves of one feature disagreed: an empty value built the URL
`/latest-release.json`, which reqwest rejects as relative, instead of
falling back to the default host.

The rest is plumbing: `MERGIFY_CLI_TESTING_UTF8_MODE`, `NO_COLOR` /
`FORCE_COLOR` / `CLICOLOR_FORCE` and `self_update`'s
`MERGIFY_BASE_URL` read through `mergify_core::env`. That is the
`env` in scope in both files now; `args()` and `current_exe()` are
spelled `std::env::`, since neither is the environment.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

Change-Id: I512c50f33a89380f3d9f4a8f7a37725a875d6804
`mergify-auth` landed while this stack was in flight and its
production side already reads through `mergify_core::env`, since
`var_non_empty` predates the funnel. Only its tests were left:
`machine`'s `COMPUTERNAME` / `HOSTNAME` chain, `browser`'s
`SSH_CONNECTION` / `DISPLAY` / `WAYLAND_DISPLAY` probes, and
`with_mergify_token`.

They install an overlay now, like everywhere else, so the crate
stops mutating the process environment and drops its `temp-env`
dependency. `with_mergify_token` keeps its shape: the overlay is on
this thread and the `current_thread` runtime it builds drives the
future on that same thread, so the closure form still works and no
call site changes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Change-Id: I7d4c755cee8cc90db511ea671e5c23215300c03c
A convention nobody can enforce decays, and this one had already
decayed once: `AGENTS.md` told contributors to use `temp_env` "never
the unsound process-global `std::env::set_var` (`unsafe_code =
"forbid"` bans it anyway)". Both halves were wrong. `temp_env` calls
`set_var`, from inside a dependency, where the workspace's
`forbid(unsafe_code)` does not reach.

`unsafe_code = "forbid"` was already the guard against *our* code
mutating the environment: `set_var` and `remove_var` are `unsafe fn`.
So the new coverage is on the read side, which is what drifts:

- `clippy.toml` disallows `std::env::var`, `var_os`, `vars` and
  `vars_os`, each with its replacement in the message, so a new
  direct read fails the build with a pointer to `mergify_core::env`.
  `set_var` / `remove_var` are listed as documentation of a rule
  `forbid(unsafe_code)` already enforces, and to say what someone
  relaxing that lint would be unlocking. `set_current_dir` joins
  them: it is the *safe* process-global mutator, it races every
  relative path in every other test thread, and two existing comments
  (`mergify-config/src/paths.rs`, `mergify-ci/src/scopes_detect/
  changed_files.rs`) show contributors were already tempted by it.
- `deny.toml` bans the `temp-env` crate, since no lint over our
  source can see a `set_var` that happens inside a dependency. It
  blocks the one we used, not the class: cargo-deny cannot express
  "nothing that calls setenv", and the file says so.

Two explicit allows, both for reads that are not the process
environment. `build.rs` reads cargo's environment for this one
invocation and cannot depend on `mergify-core`. `live_smoke.rs`
copies the parent's environment into the child it spawns, and does it
with `vars_os` now: `vars` panics on a single variable that is not
valid Unicode, which would have taken down every case in that file
before it spawned anything.

`AGENTS.md` states the rule with its reason, since the next person
needs the argument and not just the rule, and with the two things
that are easy to get wrong: an overlay hides the host environment,
and it does not reach a dependency or a child process.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

Change-Id: I185b16b8d8b1c65f325301628c1e6b1d1de789c1
@mergify
mergify Bot deployed to Mergify Merge Protections September 21, 2026 12:55 Active
@mergify
mergify Bot deployed to func-tests-live September 21, 2026 12:55 Active
@mergify mergify Bot closed this Sep 21, 2026
@mergify
mergify Bot deleted the mergify/merge-queue/bb3dadc6e0 branch September 21, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant