Add migration to fix parameter value types for alert conditions #3340
Conversation
Other than the issues in the comments, the changes seem to work and the tests also pass. |
...erver/src/main/java/org/graylog2/migrations/V20170110150100_FixAlertConditionsMigration.java
Outdated
if (!(fieldValue instanceof String)) { | ||
LOG.warn("Field <{}> in alert condition <{}> of stream <{}> is not a string but a <{}>, not trying to convert it!", | ||
field, alertConditionId, streamId, fieldValue.getClass().getCanonicalName()); | ||
return; |
edmundoa
Jan 11, 2017
Member
I think in this case we should only log the situation and continue converting other fields. This situation may happen with alert conditions created before 2.0. See ea4aa95 for more information.
I think in this case we should only log the situation and continue converting other fields. This situation may happen with alert conditions created before 2.0. See ea4aa95 for more information.
bernd
Jan 12, 2017
Author
Member
Oh, good catch! That should have been a continue
.
Oh, good catch! That should have been a continue
.
...erver/src/main/java/org/graylog2/migrations/V20170110150100_FixAlertConditionsMigration.java
Outdated
} | ||
|
||
if (!(fieldValue instanceof String)) { | ||
LOG.warn("Field <{}> in alert condition <{}> of stream <{}> is not a string but a <{}>, not trying to convert it!", |
edmundoa
Jan 11, 2017
Member
Could we also add the alert condition title if available?
Could we also add the alert condition title if available?
...erver/src/main/java/org/graylog2/migrations/V20170110150100_FixAlertConditionsMigration.java
Outdated
final String stringValue = parameters.get(field, String.class); | ||
final Integer intValue = Ints.tryParse(stringValue); | ||
|
||
LOG.info("Converting value for field <{}> from string to integer in alert condition <{}> of stream <{}>", field, alertConditionId, streamId); |
edmundoa
Jan 11, 2017
Member
I would also add the alert condition title here.
I would also add the alert condition title here.
At one point at the beginning of the 2.2 development the values for integer parameters have been stored as strings in MongoDB. This has been fixed but existing broken documents need to be fixed.
Addressed all comments. Thanks! |
LGTM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
At one point at the beginning of the 2.2 development the values for integer parameters have been stored as strings in MongoDB. This has been fixed but existing broken documents need to be fixed.