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

Creating resources manually through low code #3

Open
manishagupta81 opened this issue Nov 12, 2024 · 5 comments
Open

Creating resources manually through low code #3

manishagupta81 opened this issue Nov 12, 2024 · 5 comments
Labels

Comments

@manishagupta81
Copy link

Description

Issue with Adding Resource in WSO2 Quick Start Guide

While following the WSO2 Quick Start Guide to create a new resource, I encountered issues when adding a resource manually through Connections -> externalEP -> get. Here are the details:

Steps to Reproduce

  1. Entered the resource path /zvdz/mi-qsg/v1.0 (without quotes).
    • The path was truncated.
  2. Entered the resource path with quotes "/zvdz/mi-qsg/v1.0".
    • The resource was added, but the following errors were displayed:
      • invalid type for worker send 'ballerina/http:2.12.2:Client', expected value:Cloneable
      • invalid usage of the 'check' expression operator: no expression type is equivalent to error type
      • undefined worker '$missingNode$_0'
      • missing function keyword

Observation

When I generated the resource using AI, it ran successfully without any errors.

Steps to Reproduce

I still need to try with my upgraded VSCode and mac os

Steps to Reproduce

  1. Add everything manually.
  2. Enter the resource path /zvdz/mi-qsg/v1.0 (without quotes).
    • The path was truncated.
  3. Entered the resource path with quotes "/zvdz/mi-qsg/v1.0".
    • The resource was added, but the following errors were displayed:
      • invalid type for worker send 'ballerina/http:2.12.2:Client', expected value:Cloneable
      • invalid usage of the 'check' expression operator: no expression type is equivalent to error type
      • undefined worker '$missingNode$_0'
      • missing function keyword

Version

VS Code version 1.95

Environment Details (with versions)

macOS Sequoia 15.1

@manishagupta81
Copy link
Author

Screenshot 2024-11-11 at 9 19 41 PM Screenshot 2024-11-11 at 9 21 00 PM Screenshot 2024-11-11 at 9 21 16 PM

@hasithaa
Copy link
Contributor

Thank you for reporting this issue.

This is a known limitation in the current form. Currently, only special alphanumeric characters separated by a slash (/) are supported. To include special characters, they need to be escaped using \. We are working on a fix that will be available in a future update.

Workaround

Use the following rules to make the URI path compatible with Ballerina syntax:

Rules:

  1. Paths should start with a slash, but should not end with a slash.
  2. Path subdirectories must contain alphanumeric characters and start with a letter.
  3. Path subdirectories are separated by slashes.
  4. To escape special characters and leading numbers, use a backslash (\).
    • Example:
      • /zvdz/mi-qsg/v1.0 becomes /zvdz/mi\-qsg/v1\.0.
      • /abc/123/ becomes /abc/\123
  5. Ballerina keywords such as json, string, int, service, client, etc. should be prefixed with a single quote (').
    • Example: 'service, 'int, 'client.

Recover Existing Code

  • Currently, users need to switch to the source code and manually correct the Ballerina syntax errors. To switch to the source code, click the </> icon on the file tab, located next to the run button.

Proposed Solution Expected from the Team:

  1. Immediate: Add basic form validation for the response path field to validate the above rules.
  2. Future: Improve the UX to handle each URI subdirectory separately and manage encoding/decoding for Ballerina syntax.

@manishagupta81
Copy link
Author

Thank you. I will need to fix it through code.
But i wanted to show you the below screenshot
Get greeting() was created with AI
Get greetingwithnoAI() was being created manually with low code.
Screenshot 2024-11-13 at 8 37 28 PM

@manishagupta81
Copy link
Author

As a next step, I tried to fix it manually and I observe below, Not sure if need escape seq here.
Screenshot 2024-11-13 at 8 42 38 PM

@hasithaa
Copy link
Contributor

@manishagupta81 Thank you for your valuable feedback. You've brought up an important point.

As a next step, I tried to fix it manually and I observe below, Not sure if need escape seq here.

There's a slight syntax error in your code. You can fix it by following these steps in the low-code view:

  1. Remove the node from the diagram (or the corresponding line from the source code).
  2. Add the http:Get action back to the diagram from the coneections.
  3. In the form, provide the escaped value (/zvdz/mi\-gsg/v1\.0) in the Resource Path field.

This should resolve the issue you're experiencing. It should generate the correct syntax in the source code.

json jsonResult = check externalEP->/zvdz/mi\-gsg/v1\.0

Explanation

Let me clarify the difference between the HTTP client usage of greeting and greetingwithnoAI, as there is a slight syntax variation. In Ballerina, client actions can be written in two styles: RPC (remote methods) or resource access (resource methods).

  1. The greeting function uses the remote style: cl->get("/zvdz/mi-gsg/v1.0"). Here, the path is a string value.
  2. The greetingwithnoAI function should be generated as cl->/zvdz/mi\-gsg/v1\.0. In this case, the path is a URI template.

The HTTP connections expose both of these variations, but we had to pick one to present in the low-code view to keep the UX uncluttered. We chose the resource access syntax, but it seems the remote style might provide a better experience.

We will re-evaluate the design and update the UX accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants