import json, sys
allowed = ('service', 'environment', 'state', 'eventRef')
for row in json.load(open(sys.argv[1], encoding='utf-8')):
    result = {key: row[key] for key in allowed if isinstance(row.get(key), str)}
    if len(result) != len(allowed):
        raise ValueError('Incomplete approved notification summary')
    if any(len(value) > 120 for value in result.values()):
        raise ValueError('Summary field exceeds its reviewed bound')
    print(json.dumps(result))
# Do not forward the original object on this program's failure path.
