Extract resolve_worker_target from the drifted worker-apply/upgrade duplication - #963
Merged
Merged
Conversation
…grade control_worker_apply and control_worker_upgrade duplicated the entire worker-resolution block line-for-line (name charset pin, the three WORKER_LIST_JQ lookups, host-empty/host-charset/port/token guards) — the next edit to any of those rules would land in one verb and silently not the other. Both verbs now call a single resolve_worker_target, which also picks up the existing is_valid_port() helper instead of re-deriving the same port-range check inline. Tier-1 rejection-table coverage for both verbs is unchanged and passes as proof the refactor is behavior-preserving. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #927. control_worker_apply and control_worker_upgrade duplicated the worker-resolution block nearly line-for-line — the name charset pin, the three WORKER_LIST_JQ lookups, the host/port/token guards — the exact drift class the shared-function rule exists for, in fleet-control code.
One
resolve_worker_targetnow owns it: resolves the dial target from the HOST's own config.json (never the caller's intent — the SSRF rule), preserves both charset pins verbatim (including the LC_ALL=C byte-range lesson), fails closed on missing host/token, and hands back RESOLVED_* or an operator-facing error — callers keep their own rejection/audit shapes since the verbs audit under different names. Also folds the port check onto the existing is_valid_port instead of a third regex copy.Behavior byte-identical: the tier-1 rejection tables for both verbs pass UNCHANGED (they are the proof). Solo suite 2271/0, lint clean. Ponytail: net +2 lines, kills the drift.
🤖 Generated with Claude Code