-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: add disabled validator and API config placeholders for streams #6903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
A JIRA Issue ID is missing from your branch name, PR title and PR description! 🦄 Your branch: feature/streaming-enable-all Your PR title: feat: add disabled validator and API config placeholders for streams Your PR description: - Add EnableAll config option to disable streams validator, e.g. enable all components - Add support for using API configuration in stream configs, $api_config.key Related IssueMotivation and ContextHow This Has Been TestedScreenshots (if appropriate)Types of changes
Checklist
If this is your first time contributing to this repository - welcome! Please refer to jira-lint to get started. Without the JIRA Issue ID in your branch name you would lose out on automatic updates to JIRA via SCM; some GitHub status checks might fail. Valid sample branch names:‣ feature/shiny-new-feature--mojo-10' |
- Add EnableAll config option to disable streams validator - Add support for placeholders in stream configs - Add tests for API config placeholders and disabled validator
a415e7b
to
52739ae
Compare
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
API Changes --- prev.txt 2025-05-21 07:23:51.114654503 +0000
+++ current.txt 2025-05-21 07:23:46.752673464 +0000
@@ -5154,6 +5154,11 @@
ValidateOASObjectWithBentoConfigValidator validates a Tyk Streams document
against a particular OAS version and takes an optional ConfigValidator
+func ValidateOASObjectWithConfig(documentBody []byte, oasVersion string, disableValidator bool) error
+ ValidateOASObjectWithConfig validates a Tyk Streams document against a
+ particular OAS version, using the provided configuration to determine if
+ validation should be disabled.
+
func ValidateOASTemplate(documentBody []byte, oasVersion string) error
ValidateOASTemplate checks a Tyk Streams OAS API template for necessary
fields, acknowledging that some standard Tyk OAS API fields are optional in
@@ -5170,6 +5175,7 @@
const (
DefaultBentoConfigSchemaName string = "bento-config-schema.json"
DefaultValidator ValidatorKind = "default-validator"
+ EnabledAll ValidatorKind = "enabled-all"
)
TYPES
@@ -5186,6 +5192,16 @@
func (v *DefaultConfigValidator) Validate(document []byte) error
+type EnableAllConfigValidator struct{}
+ EnableAllConfigValidator is a validator that skips all validation
+
+func NewEnableAllConfigValidator() *EnableAllConfigValidator
+ NewEnableAllConfigValidator creates a new validator that skips all
+ validation
+
+func (v *EnableAllConfigValidator) Validate(_ []byte) error
+ Validate always returns nil, effectively enabling all configurations
+
type ValidatorKind string
# Package: ./apidef/streams/bento/schema
@@ -6785,6 +6801,8 @@
// are filtered out. This field allows administrators to explicitly permit specific unsafe components when needed.
// Use with caution as enabling unsafe components may introduce security vulnerabilities.
AllowUnsafe []string `json:"allow_unsafe"`
+ // EnableAll enables all Bento plugins (except unsafe ones) by disabling the streams validator
+ EnableAll bool `json:"enable_all"`
}
StreamingConfig holds the configuration for Tyk Streaming functionalities
|
/probe review |
/probe review |
/probe review |
/probe review |
@buger Sorry, but I do not understand! |
/probe review |
@buger Sorry, but I do not understand! |
/probe review |
@buger Sorry, but I do not understand! |
/probe review |
@buger Sorry, but I do not understand! |
/probe review |
@buger Sorry, but I do not understand! |
/probe review |
@buger Sorry, but I do not understand! |
/probe review |
@buger Sorry, but I do not understand! |
Error during chat processing: Error: Failed to get response from AI model during iteration 1. Failed after 3 attempts. Last error: Bad Gateway Tip: Start comment with |
/probe review |
@buger Sorry, but I do not understand! |
Error during chat processing: Error: Failed to get response from AI model during iteration 23. prompt is too long: 202797 tokens > 200000 maximum Tip: Start comment with |
/probe review this PR |
Code Review: Add Disabled Validator and API Config Placeholders for StreamsThis PR introduces two significant enhancements to Tyk's streaming functionality: 1. EnableAll Validator for StreamsThe PR adds a new validator type that bypasses validation checks, effectively enabling all components in stream configurations except unsafe ones. This is implemented through:
Strengths:
Concerns:
2. API Config Placeholders in Stream ConfigurationsThe PR adds support for using API configuration values in stream configurations via
Strengths:
Concerns:
TestsThe PR includes comprehensive tests for both features:
Overall AssessmentThe PR is well-implemented and follows existing patterns in the codebase. The features provide valuable flexibility for stream configurations. However, there are a few improvements that should be considered:
The test coverage is good, with tests for both normal operation and edge cases. The code is clean and follows the project's conventions. Recommendation: Approve with the suggested improvements, particularly the nil check for Tip: Mention me again using |
|
### **User description** <details open> <summary><a href="https://tyktech.atlassian.net/browse/TT-14731" title="TT-14731" target="_blank">TT-14731</a></summary> <br /> <table> <tr> <th>Summary</th> <td>Add a flag to enable all bento inputs/outputs</td> </tr> <tr> <th>Type</th> <td> <img alt="Story" src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10315?size=medium" /> Story </td> </tr> <tr> <th>Status</th> <td>In Dev</td> </tr> <tr> <th>Points</th> <td>N/A</td> </tr> <tr> <th>Labels</th> <td>-</td> </tr> </table> </details> <!-- do not remove this marker as it will break jira-lint's functionality. added_by_jira_lint --> --- Re-opened and cleaned version of this PR: #6903 This was a required move to use the latest tyk-analytics code for api-tests. ___ ### **PR Type** Enhancement, Tests ___ ### **Description** - Add `EnableAll` flag to streaming config to disable Bento validator - Implement `EnableAllConfigValidator` to bypass Bento config validation - Update stream loading to support all Bento plugins via single import - Add and extend tests for validator disabling and config placeholder support ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>4 files</summary><table> <tr> <td><strong>config.go</strong><dd><code>Add EnableAll flag to StreamingConfig struct</code> </dd></td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7065/files#diff-fe44f09c4d5977b5f5eaea29170b6a0748819c9d02271746a20d81a5f3efca17">+2/-0</a> </td> </tr> <tr> <td><strong>validator.go</strong><dd><code>Implement EnableAllConfigValidator to skip validation</code> </dd></td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7065/files#diff-462103c9f2f33bbe3bd4a21e46b5614fa0a4bfc3c3774f6c5f2ef858ae3fbb3f">+14/-0</a> </td> </tr> <tr> <td><strong>validator.go</strong><dd><code>Add logic to use EnableAll validator and new validation entrypoint</code></dd></td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7065/files#diff-351cfcacb241ec2c3a3172d8c17e1217d6e942b5962081e7f9fd1582e801ca7f">+16/-0</a> </td> </tr> <tr> <td><strong>stream.go</strong><dd><code>Import all Bento plugins via single import</code> </dd></td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7065/files#diff-12571ea9605d5a2dd5ab5aa36972649881f87a84a39b7074213d29d24fc396a8">+2/-8</a> </td> </tr> </table></details></td></tr><tr><td><strong>Tests</strong></td><td><details><summary>3 files</summary><table> <tr> <td><strong>validator_test.go</strong><dd><code>Add tests for EnableAll validator and config validation</code> </dd></td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7065/files#diff-a2b6f11dd78fabd9764d82f19af456f7b2bb835951d49e5e79d3488240513d0a">+63/-2</a> </td> </tr> <tr> <td><strong>mw_streaming_test.go</strong><dd><code>Minor test cleanup and reliability improvements</code> </dd></td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7065/files#diff-a0d1bd0196a741537a3c850e340225c8993e49d709c838af0f1b48b9893af1da">+10/-33</a> </td> </tr> <tr> <td><strong>mw_streaming_mqtt_test.go</strong><dd><code>Fix test cleanup and error handling for WebSocket clients</code></dd></td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7065/files#diff-09d30d4ab7dc29a32af2e23e40cf873770963e4ee54c4a0bff4e83200e9d4926">+4/-3</a> </td> </tr> </table></details></td></tr><tr><td><strong>Dependencies</strong></td><td><details><summary>1 files</summary><table> <tr> <td><strong>go.mod</strong><dd><code>Update gopsutil version and add indirect dependencies</code> </dd></td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7065/files#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6">+234/-12</a></td> </tr> </table></details></td></tr><tr><td><strong>Additional files</strong></td><td><details><summary>2 files</summary><table> <tr> <td><strong>middleware.go</strong></td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7065/files#diff-0ce428c0f09dca65e3df6e72d01fee63b6f237785e41e6ecf0ce34a8b65c74a5">+0/-1</a> </td> </tr> <tr> <td><strong>go.sum</strong></td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7065/files#diff-3295df7234525439d778f1b282d146a4f1ff6b415248aaac074e8042d9f42d63">+2228/-22</a></td> </tr> </table></details></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details> --------- Co-authored-by: Leonid Bugaev <[email protected]>
<details open> <summary><a href="https://tyktech.atlassian.net/browse/TT-14731" title="TT-14731" target="_blank">TT-14731</a></summary> <br /> <table> <tr> <th>Summary</th> <td>Add a flag to enable all bento inputs/outputs</td> </tr> <tr> <th>Type</th> <td> <img alt="Story" src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10315?size=medium" /> Story </td> </tr> <tr> <th>Status</th> <td>In Dev</td> </tr> <tr> <th>Points</th> <td>N/A</td> </tr> <tr> <th>Labels</th> <td>-</td> </tr> </table> </details> <!-- do not remove this marker as it will break jira-lint's functionality. added_by_jira_lint --> --- Re-opened and cleaned version of this PR: #6903 This was a required move to use the latest tyk-analytics code for api-tests. ___ Enhancement, Tests ___ - Add `EnableAll` flag to streaming config to disable Bento validator - Implement `EnableAllConfigValidator` to bypass Bento config validation - Update stream loading to support all Bento plugins via single import - Add and extend tests for validator disabling and config placeholder support ___ <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>4 files</summary><table> <tr> <td><strong>config.go</strong><dd><code>Add EnableAll flag to StreamingConfig struct</code> </dd></td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7065/files#diff-fe44f09c4d5977b5f5eaea29170b6a0748819c9d02271746a20d81a5f3efca17">+2/-0</a> </td> </tr> <tr> <td><strong>validator.go</strong><dd><code>Implement EnableAllConfigValidator to skip validation</code> </dd></td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7065/files#diff-462103c9f2f33bbe3bd4a21e46b5614fa0a4bfc3c3774f6c5f2ef858ae3fbb3f">+14/-0</a> </td> </tr> <tr> <td><strong>validator.go</strong><dd><code>Add logic to use EnableAll validator and new validation entrypoint</code></dd></td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7065/files#diff-351cfcacb241ec2c3a3172d8c17e1217d6e942b5962081e7f9fd1582e801ca7f">+16/-0</a> </td> </tr> <tr> <td><strong>stream.go</strong><dd><code>Import all Bento plugins via single import</code> </dd></td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7065/files#diff-12571ea9605d5a2dd5ab5aa36972649881f87a84a39b7074213d29d24fc396a8">+2/-8</a> </td> </tr> </table></details></td></tr><tr><td><strong>Tests</strong></td><td><details><summary>3 files</summary><table> <tr> <td><strong>validator_test.go</strong><dd><code>Add tests for EnableAll validator and config validation</code> </dd></td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7065/files#diff-a2b6f11dd78fabd9764d82f19af456f7b2bb835951d49e5e79d3488240513d0a">+63/-2</a> </td> </tr> <tr> <td><strong>mw_streaming_test.go</strong><dd><code>Minor test cleanup and reliability improvements</code> </dd></td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7065/files#diff-a0d1bd0196a741537a3c850e340225c8993e49d709c838af0f1b48b9893af1da">+10/-33</a> </td> </tr> <tr> <td><strong>mw_streaming_mqtt_test.go</strong><dd><code>Fix test cleanup and error handling for WebSocket clients</code></dd></td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7065/files#diff-09d30d4ab7dc29a32af2e23e40cf873770963e4ee54c4a0bff4e83200e9d4926">+4/-3</a> </td> </tr> </table></details></td></tr><tr><td><strong>Dependencies</strong></td><td><details><summary>1 files</summary><table> <tr> <td><strong>go.mod</strong><dd><code>Update gopsutil version and add indirect dependencies</code> </dd></td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7065/files#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6">+234/-12</a></td> </tr> </table></details></td></tr><tr><td><strong>Additional files</strong></td><td><details><summary>2 files</summary><table> <tr> <td><strong>middleware.go</strong></td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7065/files#diff-0ce428c0f09dca65e3df6e72d01fee63b6f237785e41e6ecf0ce34a8b65c74a5">+0/-1</a> </td> </tr> <tr> <td><strong>go.sum</strong></td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7065/files#diff-3295df7234525439d778f1b282d146a4f1ff6b415248aaac074e8042d9f42d63">+2228/-22</a></td> </tr> </table></details></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details> --------- Co-authored-by: Leonid Bugaev <[email protected]>
User description
Related Issue
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist
PR Type
Enhancement, Tests, Configuration changes
Description
Introduced
EnableAll
validator to bypass stream validation.Added support for
$api_config
placeholders in stream configurations.Enhanced test coverage for new validator and API config placeholders.
Updated dependencies and configuration structures for streaming.
Changes walkthrough 📝
4 files
Added `EnableAll` validator to bypass validation.
Integrated `EnableAll` validator into stream validation logic.
Integrated `EnableAll` validator into middleware validation.
Added support for `$api_config` variable replacement.
2 files
Added tests for `EnableAll` validator and API config placeholders.
Enhanced streaming tests with new configurations and scenarios.
1 files
Added `EnableAll` flag to streaming configuration.
2 files
Updated Bento components import for streaming.
Updated dependencies for streaming and validation enhancements.
1 files