Keep ErrOperationOnFunctionNotSupported matchable and stop logging it as an error - #256
Keep ErrOperationOnFunctionNotSupported matchable and stop logging it as an error#256andig wants to merge 1 commit into
Conversation
… as an error requestData rendered the sentinel to a string and rebuilt it with errors.New, so errors.Is could never match it and callers had no way to tell an expected capability gap from a real failure. Wrap it instead, and align the remaining use cases with the majority that already log these connect-time discovery requests at debug level.
|
This is another consistency issue that should end up on the implementation quality checklist. |
|
One thing worth flagging before this is merged: 13 open PRs add new connect-time
All of them are the same class as the ones aligned here: best-effort discovery on connect, where the remote is free not to implement the optional function. Whichever side merges last wins, so the outcome is either a follow-up sweep or a conflict-prone rebase. Happy to flip these to debug in the respective branches ahead of time — say the word and I will push that to mine (#232, #233, #240–#249); #132 is not mine. No merge conflicts with any currently open PR, for what it's worth: #207 touches the same Related: #251 introduces 🤖 Generated with Claude Code |
ErrOperationOnFunctionNotSupportedis declared inapi/errors.gobut has exactly one use, and that use throws the sentinel away:errors.Iscan never match it, so neither the use cases nor any downstream consumer can distinguish "the remote does not implement this optional function" from a real failure. This wraps it instead. The rendered message is unchanged.The second half is a consistency fix. Connect-time discovery requests are best-effort — the remote is free not to implement optional functions — and most use cases already log their failures at debug level:
cs/lpc,cs/lpp,eg/lpc,eg/lpp,cem/evcc,cem/evcem,cem/cevc,cem/opev,cem/evsoc,cem/ohpcf. Five files still log the same class of request at error level, andeg/lpc/eg/lppare inconsistent within themselves — everyRequest*call is debug exceptRequestKeyValues. This aligns the outliers.What prompted it: a NIBE VVM S320 heat pump. Its Measurement server declares
measurementListDataandmeasurementDescriptionListDataand nothing else, which is legal —measurementConstraintsListDatais optional.ma/mpcrequests constraints unconditionally on connect for every compatible entity, so the device produces two lines like this on every connection, forever:The use case works fine — descriptions arrive,
DataUpdatePowerstreams normally — but users reasonably read a red ERROR as the reason their device is not working and open bug reports about it.Verified:
go vet ./...clean,go test ./...green.usecases/api/types.gois reported bygofmt -londevas well and is left untouched.🤖 Generated with Claude Code