Conversation
Signed-off-by: Dwi Siswanto <git@dw1.io>
WalkthroughThe change updates the error handling in the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Request
participant EngineFactory
User->>Request: Compile(options)
Request->>EngineFactory: NewGoZeroEngine()
alt Engine creation fails
alt options.Validate is true
Request->>Request: Log error, continue
else options.Validate is false
Request->>User: Return error
end
else Engine creation succeeds
Request->>Request: Assign engine
end
Request-->>User: Return (success or continue)
Assessment against linked issues
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
pkg/protocols/code/code.go (1)
99-113: Consider condensing the TODO comment for better maintainability.While the detailed explanation is valuable, the comment is quite lengthy and includes external URLs that may become stale over time. Consider:
- Moving the detailed technical discussion to documentation or an issue
- Keeping a more concise comment in the code
- Using issue references instead of direct URLs
- // NOTE(dwisiswant0): In validation mode, skip engine avail check to - // allow template validation w/o requiring all engines to be installed - // on the host. - // - // TODO: Ideally, error checking should be done at the lowest level. For - // example, we can reuse errors[1][2] from the `projectdiscovery/gozero` - // package and wrap (yes, not string format[3][4]) em inside - // `projectdiscovery/utils/errors` package to preserve error semantics - // and enable runtime type assertion via builtin `errors.Is` function - // for granular err handling in the callstack. - // - // [1]: https://github.com/projectdiscovery/gozero/blob/v0.0.3/gozero.go#L20 - // [2]: https://github.com/projectdiscovery/gozero/blob/v0.0.3/gozero.go#L35 - // [3]: https://github.com/projectdiscovery/utils/blob/v0.4.21/errors/enriched.go#L85 - // [4]: https://github.com/projectdiscovery/utils/blob/v0.4.21/errors/enriched.go#L137 + // NOTE(dwisiswant0): In validation mode, skip engine availability check to + // allow template validation without requiring all engines to be installed. + // TODO: Improve error handling semantics by wrapping errors from gozero + // package to enable runtime type assertion via errors.Is function.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
pkg/protocols/code/code.go(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
pkg/protocols/code/code.go (1)
pkg/types/types.go (1)
Options(32-464)
🔇 Additional comments (2)
pkg/protocols/code/code.go (2)
97-97: Error message formatting is clear and informative.The error message provides good context including template ID and the specific engines that are unavailable.
114-118: Conditional error handling logic is correct and aligns with PR objectives.The implementation properly distinguishes between validation mode (log error, continue) and normal mode (return error). This allows template validation to proceed even when engines are unavailable, which matches the PR requirements.
Signed-off-by: Dwi Siswanto <git@dw1.io>
* feat(code): log unavail engines as an err while validating Signed-off-by: Dwi Siswanto <git@dw1.io> * chore(chore): i meant highest level Signed-off-by: Dwi Siswanto <git@dw1.io> --------- Signed-off-by: Dwi Siswanto <git@dw1.io>
Proposed changes
Closes #6303
Also leave some notes.
Proof
Checklist
Summary by CodeRabbit