Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: API Aggregation cookbook examples not work for me. #908

Closed
grootpiano opened this issue Jan 28, 2023 · 2 comments
Closed

[Bug]: API Aggregation cookbook examples not work for me. #908

grootpiano opened this issue Jan 28, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@grootpiano
Copy link
Contributor

Describe the bug
Hi there, I have some trouble when walking through our API Aggregation cookbook. Need HELP! 🆘

There's two kind of problems:

Problem 1
In scenario 1 and 2, when using example specs, I got this error:

2023-01-28T13:37:57.542+08:00   WARN    builder/responsebuilder.go:131  ResponseBuilder(buildResponse): failed to build response info: yaml: line 1: did not find expected key
2023-01-28T13:37:57.542+08:00   ERROR   httpserver/mux.go:225   server-demo: response is nil

And I found that, in line pkg/filters/builder/builder.go:65, the result which should be unmarshaled was an invalid YAML data:

statusCode: 200
body: "[{"mega":"ease"}, {"hello":"world"}, {"hello":"new world"}]"
----------^

After changing the ResponseBuilder template like this:

diff --git a/doc/cookbook/api-aggregation.md b/doc/cookbook/api-aggregation.md
index 4107e7c0..e980c73a 100644
--- a/doc/cookbook/api-aggregation.md
+++ b/doc/cookbook/api-aggregation.md
@@ -68,7 +68,8 @@ filters:
   kind: ResponseBuilder
   template: |
     statusCode: 200
-    body: "[{{.responses.demo1.Body}}, {{.responses.demo2.Body}}, {{.responses.demo3.Body}}]"
+    body: |
+      [{{.responses.demo1.Body}}, {{.responses.demo2.Body}}, {{.responses.demo3.Body}}]

@@ -147,7 +148,8 @@ filters:
   kind: ResponseBuilder
   template: |
     statusCode: 200
-    body: "{{mergeObject .responses.demo1.JSONBody .responses.demo2.JSONBody .responses.demo3.JSONBody | toRawJson}}"
+    body: |
+      {{mergeObject .responses.demo1.JSONBody .responses.demo2.JSONBody .responses.demo3.JSONBody | toRawJson}}

then it works.

Problem 2
In scenario 3, when I stopped service demo1 and called the api again. It directly jumped to the END filter, not calling service demo2 and demo3.

So, I added a jumpIf condition:

diff --git a/doc/cookbook/api-aggregation.md b/doc/cookbook/api-aggregation.md
index 4107e7c0..e980c73a 100644
--- a/doc/cookbook/api-aggregation.md
+++ b/doc/cookbook/api-aggregation.md
@@ -181,6 +183,8 @@ flow:
   namespace: demo3
 - filter: proxy-demo1
   namespace: demo1
+  jumpIf:
+    serverError: "proxy-demo2"
 - filter: proxy-demo2
   namespace: demo2

then I got the expected result.

Version
The latest master branch version.

Additional context
Actually, I'm not sure if the modifications above are needed. Or maybe I forgot to configure something? I don't know. Please help me to figure it out. 😿


Thanks for contributing 🎉!

@grootpiano grootpiano added the bug Something isn't working label Jan 28, 2023
@localvar
Copy link
Collaborator

Thanks @grootpiano for pointing these issues out, and much appreciate if you could submit a PR to fix them.

@grootpiano
Copy link
Contributor Author

Thanks @grootpiano for pointing these issues out, and much appreciate if you could submit a PR to fix them.

That's so sure. It's my pleasure! Waiting, the PR is on the way. 🏃

grootpiano added a commit to grootpiano/easegress that referenced this issue Jan 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants