Fix error when there's an empty 'mask' in bitops config#350
Fix error when there's an empty 'mask' in bitops config#350PhillypHenning merged 1 commit intomainfrom
Conversation
|
For the record, this is a follow-up to #345 implementation where we get the following error: @PhillypHenning Is it happening when the |
|
Yep! |
| if BITOPS_logging_masks is None: | ||
| return message |
There was a problem hiding this comment.
How about specifying the right default for the empty mask? I believe it's a list by default.
Maybe adding else [] instead of else None here would save us from future issues?
bitops/scripts/plugins/settings.py
Lines 126 to 130 in d5f625e
WDYT?
There was a problem hiding this comment.
Additionally, looks like we've missed adding new mask to bitops schema here:
https://github.com/bitovi/bitops/blob/main/bitops.schema.yaml
There was a problem hiding this comment.
I disagree - personally if the value is "" then it should be a none type. None type checking is fast and accurate. Variables being half set isn't a great pattern.
There was a problem hiding this comment.
Yeah, I understand what you mean.
I just see similar errors in so many places as we're fixing those.
For instance, if schema says bitops: is an object, - yeah after parsing yaml technically empty value is None, but it's much better for us to consider it as an empty object/dict {}.
If schema says mask: is a list, technically empty value is None, but it's much better to consider it as an empty list [].
And because we have a schema with default types it makes more sense to justify it:
Lines 40 to 45 in d5f625e
So we're casting to the default type according to the schema that we defined previously.
Technically relying on None gives us nothing, but relying on the default schema type is much more beneficial saving us from all the type & empty check issues in the long run.
|
Alright based on https://github.com/bitovi/bitops/pull/345/files#diff-3ee44309834f418383ee2f058cfc22a2dd857c38b7c85ba42c835ae4d23e2163 which details the original masking work, am I right to assume what we're really needing here is a dict schema converter? bitops.config.yaml From my perspective this is either a list object or a dict. |
|
Looks like the I would care about the highest-level |
Description
Adding mask value check. If value is set, masking will occur, if not, message it returned unmasked. This avoid null value issues.
Type of change
Please delete options that are not relevant.
Checklist: