mattermost/server/public/plugin/interface_generator
Christopher Poile 0502d6b3c5
[MM-68655] Surface RPC errors from plugin hooks (#36414)
* add WithRPCErr hooks (server-facing/internal only)

* zero _returns on RPC failure in WithRPCErr companions

Aligns the WithRPCErr template with the HooksRPCErr godoc contract: when
g.client.Call returns a transport error, gob may have partially decoded the
reply. Reassign _returns to a zero value before destructuring so callers always
receive zeroed outputs alongside a non-nil transport error.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* rename HooksRPCErr to HooksWithRPCErr for naming consistency

Every related symbol uses the WithRPCErr suffix (MessageHasBeenPostedWithRPCErr,
RunMultiPluginHookWithRPCErr, RunMultiHookWithRPCErr, etc.). Aligning the
interface name removes the only outlier and makes the convention uniform.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* rename rpcErrImpl to hooksWithRPCErrImpl

Mirrors the existing hooksImpl/Hooks naming pattern on hooksTimerLayer.

* add supervisor.HooksWithRPCErr() and drop runtime type assertion

The old path did rp.supervisor.Hooks().(HooksWithRPCErr) and handled the
"doesn't implement" branch — but that branch was structurally unreachable
(the compile-time `_ HooksWithRPCErr = (*hooksTimerLayer)(nil)` assertion
guards it).

Change supervisor.hooks from `Hooks` to the concrete `*hooksTimerLayer`
(which implements both interfaces, enforced at field assignment), add a
parallel HooksWithRPCErr() accessor, and call it directly. Hooks() keeps
its public Hooks-interface signature via implicit conversion at return.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* drop "implemented by" clause from HooksWithRPCErr godoc

Both hooksRPCClient and hooksTimerLayer satisfy the interface, and naming
implementations in interface godocs adds rot — the contract is what readers
need, not the list of wrappers.

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-05 10:41:11 -04:00
..
main.go [MM-68655] Surface RPC errors from plugin hooks (#36414) 2026-05-05 10:41:11 -04:00