Repository navigation
Conversation
Event.setUei() now trims (parsing already trims through the package's StringTrimAdapter), so Java callers such as the plugin API and the MIB parser no longer store UEIs with surrounding whitespace; a whitespace-only UEI is rejected like an empty one. Also backports the UEI-base trim in JsmiMibParser.getTrapEventUEI from develop (NMS-20603), unchanged, so it merges forward cleanly.
EventConfServiceHelper.requireUei() guards saveEvent and createEventConfEventEntities, so an upload or a plugin can no longer store an event definition whose UEI is empty after trimming.
Editing an event to a blank or missing UEI was accepted (stored empty) or failed with a 500; it is now rejected with a 400, like add and upsert. The lookup of a source's events by UEI trims its parameter.
Upload, add, upsert and edit with a padded UEI store it trimmed in the uei column and in xml_content, and the reloaded definition is found by the trimmed UEI. JSON request bodies are trimmed by the Jackson 1 JAXB provider too. These pin the eventconf package's StringTrimAdapter, which every one of these paths relies on.
With Event.setUei() now rejecting a whitespace-only UEI, a Triggered or Rearmed UEI field holding only spaces made the threshold editor fail with a 500. Both fields are now trimmed, and a blank one means no custom UEI, so the threshold config and its auto-created event definition carry the same trimmed UEI.
A rejected upload said only "Event 'uei' is required", leaving the user to hunt through the file. List every event with a blank UEI by its position and event-label instead, so one failed upload is enough to fix the file.
The edit now rejects a blank UEI before it calls the service, so the handler no longer maps every IllegalArgumentException to 400; other errors from the update return 500 again. The upload checks each file's UEIs before it opens a transaction, so a bad file never locks its source.
The edit returns 400 for a missing event, a missing enabled flag or a blank UEI, and 404 for an unknown source or event, not 500. The lookup by UEI ignores whitespace around the parameter.
One invalid plugin event definition stops all plugin event definitions from loading, with nothing in the log that names the plugin. Log the plugin's extension class, the UEI and the event-label. The behavior is unchanged; skipping the bad definition is a follow-up.
isBlank() and String.trim() disagree on control characters, so a field of only control characters reached setUei as an empty UEI and failed. Use String.trim() for both the check and the value.
marshallmassengill
left a comment
There was a problem hiding this comment.
- Trim and blank checks: Event.setUei uses trim(), but EventConfServiceHelper.requireUei uses isBlank(). The two methods do not agree on Unicode space characters above U+0020. A UEI that contains only such characters passes setUei, and then the storage check rejects it. For a plugin, the log does not give the plugin name in this case. Use the same check in the two locations.
- EventConfRestService.java, line 512: The edit handler does the blank UEI check again in local code. Use one shared method in EventConfServiceHelper for this check. Then the REST layer and the service cannot become different.
- EventConfRestApi.java, line 1028: One line in the description of the lookup by UEI is too long. Divide the line.
- EventConfRestApi.java, edit responses: The examples for 400, 404 and 500 are JSON objects, but the schema type is string. Change the schema type to agree with the examples.
Event.setUei used String.trim(), but the storage and REST checks used isBlank(). The two disagree on control characters and on Unicode spaces such as U+2003, so a plugin UEI of only Unicode spaces passed setUei and failed later in the sync, where the log does not name the plugin. The rule is now: trim with String.trim(), then test with isBlank(). EventConfServiceHelper.isBlankUei is the shared method; the storage checks, the REST add/upsert/edit checks and the threshold form use it, and Event.setUei applies the same rule.
The edit responses are JSON objects, so their schema type is object, and the 200 example shows the real message body. Divide a long line in the description of the lookup by UEI.
|
…hitespace-f2026-smoke
…hitespace-f2026-smoke
Event configuration can keep a UEI that has whitespace around it. It can also keep a UEI that is empty.
Eventd reads each definition from
xml_content, and the parser trims the UEI. Thus, the definitions in memory are already trimmed. The problems are in other places:eventconf_events.ueicolumn kept the padded value. The lookups by UEI use this column.The XML and JSON REST paths already trim UEIs. The eventconf package has a package-level
StringTrimAdapter, and JAXB and the Jackson provider both use it. These are the real gaps:Event.setUei()does not go through the adapter. The plugin path and the threshold form are examples."".Changes
Model
Event.setUei()trims the value. It rejects a value that is blank after the trim.String.trim(), then test withString.isBlank().trim()removes control characters, andisBlank()finds Unicode spaces such as U+2003. Thus, a UEI of only these characters is blank everywhere.EventConfServiceHelper.isBlankUei()is the shared method for this rule.JsmiMibParsertrims the UEI base before it builds trap UEIs. This hunk is the same as the NMS-20603 change ondevelop, so it merges forward with no conflict.Storage
EventConfServiceHelper.requireUei()rejects an event with a null or blank UEI.event-labelof each such event:Events with no 'uei', by position: #2 (event-label 'Foo Down'), #4REST API (
/rest/eventconf)eventorenabled, or with a blankuei. It gives 404 for an unknown source or event.Plugins
event-label.Threshold form (
ThresholdController, only onfoundation-*)Behavior changes for API clients
Not in this PR
No database migration. Rows that the threshold form or a plugin stored before this change can have whitespace in the
ueicolumn. Eventd is not affected, because it parsesxml_content. For such a row:All writes now store a trimmed UEI, so this PR stops new rows of this type. Only Horizon 35 and later, and Meridian 2026, have this table.
Trim of UEIs in the threshold configuration (
triggeredUEIandrearmedUEIinBasethresholddef). A separate ticket covers this.Plugin sync: skip an invalid plugin event definition, so that the other definitions still load. This is a follow-up.
One validator for add, upsert and edit. The edit does not check
event-labelandseverity. This is a follow-up.A test for a re-upload of an existing source that has a blank UEI. The REST layer now rejects the file before the transaction, so the old events stay.
Merge forward to
developTwo files need manual work:
opennms-webapp/.../thresholds/ThresholdController.javagives a modify/delete conflict, becausedevelopdeleted this file. Keep the delete.opennms-webapp/.../thresholds/ThresholdControllerUeiTest.javamerges with no conflict, but it does not compile ondevelop. Delete it in the same merge.All other files merge with no conflict.
After the merge, a small
developPR adds a test for the threshold UEI service.External References