Skip to content

Commit 097ad87

Browse files
committed
drop_keys defaults to "*" rather than "" (in two locations), so that it gets ignored when unspecified in command line arguments.
Copy payload keys into final keys rather than just changing the variable pointer, so that inner function doesn't modify payload_keys variable (since it's used later).
1 parent c3d257b commit 097ad87

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

lightbeam/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def main(argv=None):
127127
logger=logger,
128128
selector=args.selector or "*",
129129
exclude=args.exclude or "",
130-
keep_keys=args.keep_keys or "",
130+
keep_keys=args.keep_keys or "*",
131131
drop_keys=args.drop_keys or "",
132132
query=args.query or "{}",
133133
params=args.params,

lightbeam/lightbeam.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Lightbeam:
5050
MAX_STATUS_REASONS_TO_DISPLAY = 10
5151
DATA_FILE_EXTENSIONS = ['json', 'jsonl', 'ndjson']
5252

53-
def __init__(self, config_file, logger=None, selector="*", exclude="", keep_keys="", drop_keys="", query="{}", params="", wipe=False, force=False, older_than="", newer_than="", resend_status_codes="", results_file=""):
53+
def __init__(self, config_file, logger=None, selector="*", exclude="", keep_keys="*", drop_keys="", query="{}", params="", wipe=False, force=False, older_than="", newer_than="", resend_status_codes="", results_file=""):
5454
self.config_file = config_file
5555
self.logger = logger
5656
self.errors = 0

lightbeam/util.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import re
22
import json
33
import itertools
4+
import copy
45

56
# Strips newlines from a string
67
# Replace single-quotes with backticks
@@ -59,7 +60,8 @@ def apply_selections(keys, keep, drop):
5960
for payload_key, keep_key in list(itertools.product(keys, keep)):
6061
if (keys_match(payload_key, keep_key)):
6162
final_keys.append(payload_key)
62-
else: final_keys = keys
63+
# copy rather than direct pointer assignment, so this function doesn't modify the payload_keys variable in parent code
64+
else: final_keys = keys.copy()
6365
# remove from `final_keys` keys that match `drop`
6466
if drop and drop != [""]:
6567
for payload_key, drop_key in list(itertools.product(keys, drop)):

0 commit comments

Comments
 (0)