Skip to content

Commit

Permalink
sql output: handle empty string fields paramter
Browse files Browse the repository at this point in the history
Treat an empty string `fields` parameter as unset parameter, fixing a crash in default configuration

fixes #2548
  • Loading branch information
sebix committed Jan 8, 2025
1 parent 98df0cd commit 5b6c602
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
- The requirement can only be installed on Python version < 3.12.
- Add a check on the Python version and exit if incompatible.
- Add a deprecation warning (PR#2544 by Sebastian Wagner)
- `intelmq.bots.outputs.sql.output`:
- Treat an empty string `fields` parameter as unset parameter, fixing a crash in default configuration (PR#2548 by Sebastian Wagner, fixes #2548).

### Documentation

Expand Down
4 changes: 1 addition & 3 deletions intelmq/bots/outputs/sql/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ def init(self):
def process(self):
event = self.receive_message().to_dict(jsondict_as_string=self.jsondict_as_string)

key_names = self.fields
if key_names is None:
key_names = event.keys()
key_names = self.fields or event.keys()
valid_keys = [key for key in key_names if key in event]
keys = '", "'.join(valid_keys)
values = self.prepare_values(itemgetter_tuple(*valid_keys)(event))
Expand Down

0 comments on commit 5b6c602

Please sign in to comment.