Add ability to dynamically add filter JSON fields (and test coverage)#185
Add ability to dynamically add filter JSON fields (and test coverage)#185
Conversation
…age) Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
| status = res.StatusCode | ||
| } | ||
| l.Warnf("WS %s connect attempt %d failed [%d]: %s", w.url, attempt, status, string(b)) | ||
| l.Warnf("WS %s connect attempt %d failed [%d]: %s", w.url, attempt, status, errMsg) |
There was a problem hiding this comment.
Because of the use of Custom Log this was failing to actually log the underlying error at all in the case the error wasn't data returned from the remote server (but something like a connection failure instead)
Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
| return nil | ||
| case <-ctx.Done(): | ||
| return i18n.NewError(ctx, i18n.MsgWSSendTimedOut) | ||
| case <-w.sendDone: |
There was a problem hiding this comment.
This was an edge case deadlock:
goroutine 12 [select]:
github.com/hyperledger/firefly-common/pkg/wsclient.(*wsClient).Send(0x40004d2100, {0xb86230, 0x40004be0a0}, {0x4000412770?, 0xffffffffffffffff?, 0x0?})
/go/pkg/mod/github.com/hyperledger/firefly-common@v1.5.6-0.20250629160958-9871d4332701/pkg/wsclient/wsclient.go:305 +0xd4
----- CODE THAT DOES A SEND IN AN afterConnect() CALLBACK ----
github.com/hyperledger/firefly-common/pkg/wsclient.(*wsClient).receiveReconnectLoop(0x40004d2100)
/go/pkg/mod/github.com/hyperledger/firefly-common@v1.5.6-0.20250629160958-9871d4332701/pkg/wsclient/wsclient.go:542 +0x194
created by github.com/hyperledger/firefly-common/pkg/wsclient.(*wsClient).initialConnect in goroutine 10
/go/pkg/mod/github.com/hyperledger/firefly-common@v1.5.6-0.20250629160958-9871d4332701/pkg/wsclient/wsclient.go:254 +0x68
FAIL
Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
EnriqueL8
left a comment
There was a problem hiding this comment.
Looks good - just added explanation of one piece as it wasn't obvious
| rv := buildResolveCtx(ctx, &jq.FilterJSON, options...) | ||
| for _, field := range jq.Sort { | ||
| field, isDesc := strings.CutPrefix(field, "-") | ||
| field, err := validateFilterField(ctx, fb, field, rv) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| if isDesc { | ||
| field = "-" + field | ||
| } | ||
| fb = fb.Sort(field) | ||
| } |
There was a problem hiding this comment.
This is clunky but I get why you have done this way, Sort is shared between this filter_json and filter and you need to trim prefix to remove the desc - to validate the filter which might resolve to another name and then add again. The fb.Sort can take in multiple values as well but it's fine
When processing a
JSONQueryfilter it is helpful to be able to dynamically build up a list of fields, for cases where there might be join tables to something very dynamic like a set oftags/labelsthat require an individual join for each filterable tag.FieldResolverplug extension following the existing plugin pattern forValueResolverClone()of a field set, to a new map that lets to add fieldsFinalize()will workendsWithhad been omitted form JSON Query - so added thatAdditional things found
JSONHandlerdue to a quirk where the type was ending up as[]interface{}rather than the type returned fromJSONInputValue. I've proposed a newJSONInputDecoderfor that, which lets you work around this very simply:firefly-common/pkg/ffapi/apiserver_test.go
Lines 125 to 129 in fcaa664
200rather than204return code that was specified in the liveness check, which returns aContent-Type: application/jsonwithout any body. But I just commented that rather than changing it.