Repository navigation
Conversation
…ions preHandler(), postHandler(), aroundHandler() and action advice such as preIndex() could be requested as the action, so they ran outside their normal context, and preHandler() ran twice. getHandler() now sends such a request to invalid event handling, like cbMethod methods. The rule matches how the Controller finds advice, and it only applies to the main request event, so the automatic advice calls and internal runEvent() calls keep working.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Advice detection incorrectly rejects valid preview() actions because it counts the inherited framework view() helper as an action.
1 open finding
What changed in this PR
Prevents handler advice methods from being requested directly as main actions, using ColdBox’s existing invalid-event handling.
Changes:
- Adds advice detection to handler dispatch.
- Adds fixtures and integration tests for rejected requests and preserved behavior.
| File | Description |
|---|---|
| tests/specs/integration/AdviceDispatchSpec.cfc | Tests advice rejection and normal dispatch. |
| test-harness/handlers/adviceDispatch.cfc | Provides advice and action fixtures. |
| system/web/services/HandlerService.cfc | Rejects main-event requests targeting advice. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Every handler inherits framework helpers such as view(), which _actionExists() reports but which can never run as actions (cbMethod). A handler with preview() and no view() action of its own had its preview() rejected as advice. The advice target must now be a real action.
homestar9
force-pushed
the
fix/reject-direct-advice-actions
branch
from
October 16, 2026 19:22
476830b to
395969f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Handler advice methods (
preHandler(),postHandler(),aroundHandler()and action advice such aspreIndex()) have to be visible for the framework to call them. They can also be requested as the action, for example?event=main.preHandler. ColdBox then runs the advice as the action, outside its normal context: without theactionargument, and forpreHandler, a second time as advice for the same request. The request usually fails afterwards looking for amain/preHandlerview.This PR treats such a request as an invalid event, the same way framework methods tagged
cbMethodare already treated. The check sits inHandlerService.getHandler(), right after the existingcbMethodcheck, and callsprocessInvalidEvent(). Apps get theirinvalidEventHandleror a 404, with no new exception type.The rule, in a new private helper
isAdviceAction( action, oEventHandler ), is the oneController.runEvent()already uses to find advice:preHandler,postHandleroraroundHandlerpre,postoraroundfollowed by the name of an action that exists in the same handler, case-insensitiveThe check only applies to the main request event, using the same test as the event caching block (
!ehBean.getIsPrivate() AND ehBean.getFullEvent() EQ requestContext.getCurrentEvent()). Not affected:oHandler.preHandler(...)and the other advice directly.runEvent()calls to advice or private methods.preflight()with noflight()action.Edge cases:
view()action: the framework already runspreview()as advice before everyviewrequest, so a direct?event=handler.previewis now refused as well.view()andlayout(), which are taggedcbMethodand can never run as actions. The advice target must be a real action, sopreview()in a handler without its ownview()is still a normal action. Thanks to the Copilot review for catching this.Jira Issues
Type of change
Checklist
test-harness/handlers/adviceDispatch.cfc, andadviceInherited.cfc(apreview()action with noview()action).tests/specs/integration/AdviceDispatchSpec.cfc. Direct requests forpreHandler,postHandler,aroundHandler,preIndexandpreviewreach invalid event handling.indexwith its automatic advice,preflight,preview()without aview()action, and an internalrunEvent()call topreHandlerstill work.aroundHandler, because there's notargetAction. The "still works" specs pass with and without the change.runner.cfmandrunner-integration.cfm, compared with a run ofdevelopmentwithout the change.AdviceDispatchSpec,HandlerServiceTest,EventExecutionsSpecandMainSpecpass 46/46 on each of those engines. The newpreview()spec fails without that commit.