diff options
author | Victor Näslund <victor@sunet.se> | 2022-11-16 22:24:22 +0100 |
---|---|---|
committer | Victor Näslund <victor@sunet.se> | 2022-11-16 22:24:22 +0100 |
commit | 340a77a4f120cc92192e07b95e1d4b342749cf50 (patch) | |
tree | 2959b04c86570225d3d283a3911bb37fc6adb7e9 /src/soc_collector/soc_collector_cli.py | |
parent | 0660799e8854f57951cb9e65e684348a83078424 (diff) |
Better error handling, the server already has this but defence in depth is always good
Diffstat (limited to 'src/soc_collector/soc_collector_cli.py')
-rw-r--r-- | src/soc_collector/soc_collector_cli.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/soc_collector/soc_collector_cli.py b/src/soc_collector/soc_collector_cli.py index b579108..2398e4f 100644 --- a/src/soc_collector/soc_collector_cli.py +++ b/src/soc_collector/soc_collector_cli.py @@ -115,6 +115,11 @@ def replace_action(data: str) -> None: """ json_data = json_load_data(data) + + if "_id" not in json_data: + print("ERROR: '_id' key not in data") + app_exit(1) + req = requests.put(f"{API_URL}/sc/v0", json=json_data, headers={"API-KEY": API_KEY}, timeout=5, verify=ROOT_CA_FILE) # Check status @@ -136,6 +141,11 @@ def insert_action(data: str) -> None: """ json_data = json_load_data(data) + + if "_id" in json_data: + print("ERROR: '_id' key in data") + app_exit(1) + req = requests.post( f"{API_URL}/sc/v0", json=json_data, headers={"API-KEY": API_KEY}, timeout=5, verify=ROOT_CA_FILE ) |