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

Validate required params in views #2004

Open
efgpinto opened this issue Feb 1, 2024 · 0 comments
Open

Validate required params in views #2004

efgpinto opened this issue Feb 1, 2024 · 0 comments
Labels
bug Something isnt working java-sdk kalix-runtime Runtime and SDKs sub-team views

Comments

@efgpinto
Copy link
Member

efgpinto commented Feb 1, 2024

A view with:

  @GetMapping("/wrapped/by_city")
  @Query("""
    SELECT * AS customers, next_page_token() AS token
        FROM customers_by_city
      WHERE address.city = ANY(:cities)
      OFFSET page_token_offset(:pagetoken)
      LIMIT 2
    """)
  public CustomersResponse getCustomers(@RequestParam List<String> cities, @RequestParam String pagetoken) {
    return null;
  }

When called without providing a required param, returns:

✗ curl -i "localhost:9000/wrapped/by_city?cities=Testcity"           
HTTP/1.1 500 Internal Server Error
Access-Control-Allow-Origin: *
Server: akka-http/10.6.0
Date: Thu, 01 Feb 2024 10:00:42 GMT
Content-Type: text/plain; charset=UTF-8
Content-Length: 61

Cannot invoke "Object.getClass()" because "<local14>" is null% 

On the other side, an action with:

  @GetMapping("/actionwrapped/by_city")
  public Effect<CustomersResponse> getCustomers(@RequestParam List<String> cities, @RequestParam String pagetoken) {
    return effects().forward(componentClient.forView().call(CustomersResponseByCity::getCustomers).params(cities, pagetoken));
  }

When called without a required param:

✗ curl -i "localhost:9000/actionwrapped/by_city?cities=Testcity"           
HTTP/1.1 400 Bad Request
Access-Control-Allow-Origin: *
Server: akka-http/10.6.0
Date: Thu, 01 Feb 2024 10:00:58 GMT
Content-Type: text/plain; charset=UTF-8
Content-Length: 48

Required request parameter is missing: pagetoken% 

We want to make it such that the required param is also validated when calling the view directly.

@efgpinto efgpinto added bug Something isnt working kalix-runtime Runtime and SDKs sub-team java-sdk labels Feb 1, 2024
@ennru ennru added the views label Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isnt working java-sdk kalix-runtime Runtime and SDKs sub-team views
Projects
None yet
Development

No branches or pull requests

2 participants