From 5b05ae0be01b07b270f294d87591845048438c86 Mon Sep 17 00:00:00 2001 From: Xiaoyi Shi Date: Wed, 13 May 2026 03:22:17 -0700 Subject: [PATCH] fix(tar): drop truthy-string default on store_true argparse flags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `--preserve_mode` and `--preserve_mtime` flags in `pkg/private/tar/build_tar.py` were declared with `default='False'` (a string, which is truthy) combined with `action='store_true'`. When the flags are not passed on the command line, argparse uses the default verbatim instead of the boolean `False` that `store_true` would produce, so `options.preserve_mode` and `options.preserve_mtime` end up as the string `'False'` — truthy under any natural truthy check. rules_pkg's own use happens to be safe because the check is `if self.preserve_mode is True`, but the typo is a foot-gun for anyone copying the pattern. Drop the bogus default — `action='store_true'` already defaults to boolean `False`. Fixes #1064 --- pkg/private/tar/build_tar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/private/tar/build_tar.py b/pkg/private/tar/build_tar.py index 18102073..900f2842 100644 --- a/pkg/private/tar/build_tar.py +++ b/pkg/private/tar/build_tar.py @@ -414,11 +414,11 @@ def main(): action='store_true', help='') parser.add_argument( - '--preserve_mode', default='False', + '--preserve_mode', action='store_true', help='Preserve original file permissions in the archive. Mode argument is ignored.') parser.add_argument( - '--preserve_mtime', default='False', + '--preserve_mtime', action='store_true', help='Preserve original file mtime in the archive. mtime argument is ignored.') parser.add_argument(