mirror of
https://gerrit.googlesource.com/git-repo
synced 2026-07-15 21:27:00 +00:00
git_trace2_event_log: Fix index out of range on empty config values
In git_trace2_event_log_base.py's GetDataEventName method, it parses value to identify if it represents a JSON list. When a config key has an empty string value, GetDataEventName evaluates value[0], which raises IndexError: string index out of range. This change fixes the crash by checking if the value is a string and using startswith/endswith to check for JSON lists instead of direct indexing. Test: PYTHONPATH=. pytest tests/test_git_trace2_event_log.py Bug: 512518342 TAG=agy CONV=ff5d70d7-e5b3-42b3-8f16-23b9e3070754 Change-Id: Ic40a8c6a22df57d0e97f268f6e1bc8a14a5024a4 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/602201 Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Rahul Yadav <yadavrah@google.com> Commit-Queue: Rahul Yadav <yadavrah@google.com>
This commit is contained in:
committed by
gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
547dc9985c
commit
a27dbcdb7b
@@ -315,6 +315,7 @@ def test_data_event_config(event_log: git_trace2_event_log.EventLog) -> None:
|
||||
"repo.partialclone": "false",
|
||||
"repo.syncstate.superproject.hassuperprojecttag": "true",
|
||||
"repo.syncstate.superproject.sys.argv": ["--", "sync", "protobuf"],
|
||||
"repo.syncstate.emptykey": "",
|
||||
}
|
||||
prefix_value = "prefix"
|
||||
event_log.LogDataConfigEvents(config, prefix_value)
|
||||
@@ -323,7 +324,7 @@ def test_data_event_config(event_log: git_trace2_event_log.EventLog) -> None:
|
||||
log_path = event_log.Write(path=tempdir)
|
||||
log_data = read_log(log_path)
|
||||
|
||||
assert len(log_data) == 5
|
||||
assert len(log_data) == 6
|
||||
data_events = log_data[1:]
|
||||
verify_common_keys(log_data[0], expected_event_name="version")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user