Update OPA Plugin: Error Handling and Synchronization with Plugin Framework Updates #1531
+361
−86
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.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📝 Error Handling and Synchronization with Plugin Framework Updates
OPA Plugin Error Handling
Added standardized error constants for OPA plugin failures, including server communication issues, configuration errors, and unsupported parameters or modalities. The OPA plugin now raises a PluginError for these conditions:
OPA_SERVER_NONE_RESPONSE= "OPA server returned an empty response"OPA_SERVER_ERROR= "Error while communicating with the OPA server"OPA_SERVER_UNCONFIGURED_ENDPOINT= "Policy endpoint not configured on the OPA server"UNSPECIFIED_REQUIRED_PARAMS= "Required parameters missing: policy config, payload, or hook type"UNSUPPORTED_HOOK_TYPE= "Unsupported hook type (only tool, prompt, and resource are supported)"INVALID_POLICY_ENDPOINT= "Policy endpoint must be curated with the supported hooktypes"UNSPECIFIED_POLICY_MODALITY= "Unspecified policy modality. Picking up default modality: text"UNSUPPORTED_POLICY_MODALITY= "Unsupported policy modality (Supports text, image and resource)"Testing
Included test_errors.py with unit tests verifying these errors raise correctly under respective conditions. Run tests via make test.
OPA Plugin test cases updated with the new refactoring changes
The test cases were failing before, since the way we invoke hooks from plugin manager changed with the new changes in the plugin framework. Now, with the updates, all test cases are passing