Skip to content

Commit

Permalink
empty-response-empty-table (#423)
Browse files Browse the repository at this point in the history
Summary:

- Empty response will generate empty talbe, even in the face of `jsonpath` error.
- Added robot test `Empty Response 200 Missing Jsonpath Search Key Should Return Empty Table on GCP KMS Key Rings`.
- Added robot test `Normal Response 200 Should Return Populated Table on GCP KMS Key Rings`.
  • Loading branch information
general-kroll-4-life committed Jun 3, 2024
1 parent 6173ecd commit a43c5fb
Show file tree
Hide file tree
Showing 5 changed files with 6,583 additions and 5 deletions.
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
"select * from aws.pseudo_s3.s3_bucket_polymorphic;",
"show methods in aws.pseudo_s3.s3_bucket_detail;",
"select * from aws_cc_bucket_unfiltered where data__Identifier = 'stackql-trial-bucket-01' ;",
"select * from google.cloudkms.key_rings where projectsId = 'testing-project' and locationsId = 'australia-southeast1';",
],
"default": "show providers;"
},
Expand Down
21 changes: 16 additions & 5 deletions internal/stackql/primitivebuilder/single_select_acquire.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (ss *SingleSelectAcquire) GetTail() primitivegraph.PrimitiveNode {
return ss.root
}

//nolint:funlen,gocognit,gocyclo,cyclop // TODO: investigate
//nolint:funlen,gocognit,gocyclo,cyclop,nestif // TODO: investigate
func (ss *SingleSelectAcquire) Build() error {
prov, err := ss.tableMeta.GetProvider()
if err != nil {
Expand Down Expand Up @@ -205,7 +205,13 @@ func (ss *SingleSelectAcquire) Build() error {
}
processed, resErr := m.ProcessResponse(response)
if resErr != nil {
return internaldto.NewErroneousExecutorOutput(resErr)
//nolint:errcheck // TODO: fix
ss.handlerCtx.GetOutErrFile().Write(
[]byte(fmt.Sprintf("error processing response: %s\n", resErr.Error())),
)
if processed == nil {
return internaldto.NewErroneousExecutorOutput(resErr)
}
}
res, respOk := processed.GetResponse()
if !respOk {
Expand All @@ -225,10 +231,15 @@ func (ss *SingleSelectAcquire) Build() error {
if ss.tableMeta.GetSelectItemsKey() != "" && ss.tableMeta.GetSelectItemsKey() != "/*" {
items, ok = pl[ss.tableMeta.GetSelectItemsKey()]
if !ok {
items = []interface{}{
pl,
if resErr != nil {
items = []interface{}{}
ok = true
} else {
items = []interface{}{
pl,
}
ok = true
}
ok = true
}
} else {
items = []interface{}{
Expand Down
34 changes: 34 additions & 0 deletions test/mockserver/expectations/static-gcp-expectations.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,38 @@
[
{
"httpRequest": {
"headers": {
"accept": [ "application/json" ]
},
"method": "GET",
"path": "/v1/projects/testing-project/locations/australia-southeast1/keyRings"
},
"httpResponse": {
"statusCode": 200,
"body": {}
}
},
{
"httpRequest": {
"headers": {
"accept": [ "application/json" ]
},
"method": "GET",
"path": "/v1/projects/testing-project/locations/global/keyRings"
},
"httpResponse": {
"statusCode": 200,
"body": {
"keyRings": [
{
"name": "projects/testing-project/locations/global/keyRings/testing",
"createTime": "2022-02-02T02:02:02.02000000Z"
}
],
"totalSize": 1
}
}
},
{
"httpRequest": {
"headers": {
Expand Down
Loading

0 comments on commit a43c5fb

Please sign in to comment.