Where does the server action get its data from?

NodeJS

I have simple server action:

As shown in the graphical representation in Security Login, the variables user, password, and remember have been assigned values. However, this is not reflected in the login_copy.json file, and Wappler (as shown at the bottom of the image) returns an error.
In the login_copy.json file, this corresponds to the following text:

{
  "name": "identity",
  "module": "auth",
  "action": "login",
  "options": {
    "provider": "commweb",
    "username": "{{email}}"
  },
  "output": true,
  "meta": []
}

The JSON file only contains data for the username. So why do we see values assigned to “password” and “remember” in the graphical interface?

That said, everything works correctly; I can log in to the site using this API.

Full json:

{
  "meta": {
    "options": {
      "linkedFile": "/views/login.ejs",
      "linkedForm": "login1"
    },
    "$_POST": [
      {
        "type": "text",
        "fieldName": "email",
        "options": {
          "rules": {
            "core:required": {
              "param": ""
            },
            "core:email": {
              "param": ""
            }
          }
        },
        "name": "email"
      },
      {
        "type": "text",
        "fieldName": "password",
        "options": {
          "rules": {
            "core:required": {
              "param": ""
            }
          }
        },
        "name": "password"
      },
      {
        "type": "text",
        "fieldName": "remember",
        "name": "remember"
      }
    ]
  },
  "exec": {
    "steps": [
      {
        "name": "email",
        "module": "core",
        "action": "setvalue",
        "options": {
          "value": "{{$_POST.email.lowercase()}}"
        },
        "meta": [],
        "outputType": "text"
      },
      {
        "name": "identity",
        "module": "auth",
        "action": "login",
        "options": {
          "provider": "commweb",
          "username": "{{email}}"
        },
        "output": true,
        "meta": []
      },
      {
        "name": "identity",
        "module": "auth",
        "action": "identify",
        "options": {
          "provider": "commweb"
        },
        "meta": []
      }
    ]
  }
}

In reality, I ran into a problem where a significant portion of the API files weren't being uploaded to the server (about 1/3). I started digging into it and saw the “Problems” button; then I discovered that Wappler had a lot of issues with my project, so I began looking into what exactly was wrong. I’m sure some of it has to do with the fact that an AI wrote the API for me. Somewhere, it set `type=‘json’`, but Wappler requires `“object”`. However, everything works fine—there are no issues with the API’s execution.

It’s very important to understand how Wappler works:

1. Where does Wappler get information about the server action? How is it that I see one thing in the JSON file but something else in the graphical interface?

2. How does Wappler decide which files to send to the server and which not to?

There is a walk-through available within the documentation that explains everything. Can find it here:

Thank you but my question is not about “Security and Login“, Btw security and login working propperly on my website.

I apologise. I think you have highlighted the issue hence me linking you to the documentation so you can check against it and the Action that AI created..

Sorry, but I don’t really understand what exactly you are asking. Could you please be a bit more specific and separate the exact issue from the background information?

Is the problem about the Security Login step, the Problems panel, or files not being uploaded to the server?

1 Like

We’re not discussing the file upload issue. Also, Security Logon is actually working as it should.

However, I see that the JSON file for “server action” lacks the data that I see in the Wappler graphical interface. This is evident in the screenshot, and I’ve also included the text of the JSON file.

Wappler itself drew attention to this issue—it indicated that there is no data for the “password” field. And indeed, it’s not present in the JSON file. But in the graphical interface, we see that the “password” field is assigned the value $_POST.password. Why isn’t this included in the JSON file for the server action? Wappler displays the data but at the same time reports an error stating that the data is missing.

This doesn’t seem right to me.

These are just the default values and as default values they are not present in the json. They will appear there when the values you select are different. This is by design and not an issue, and also you should not be editing anything in the server actions json files manually, as you might break the syntax/structure.

OK. Why Wappler show me the error with value for password?

Regarding editing JSON files that contain server actions. How can we not edit them in the age of AI? The AI often generates them for me, and it’s convenient. Now it turns out I need to understand what they are, since AI can sometimes cause problems….

You can safely ignore this warning, it’s being wrongly reported. Will be fixed in the next updates.

1 Like

OK.
Right now, Wappler is showing me between 50 and 140 errors. But everything is working as intended. I don't know why the number of errors keeps changing. Basically, something isn't right with these errors. Although I did fix one, and Wappler removed the error (I changed type=json to type=object, even though the JSON was working fine).

Something like this:

But everything is working :slight_smile:

As i explained you should not randomly change stuff in the server actions, as the validatior expects a specific schema and very strict syntax, changing a thing can break the whole validation.

Were these files generated by you using the Server Connect UI or were these generated via AI? When you inspect the actions which option is the actual error coming from?

login, getjson - generated by Wappler 100%
other - AI

for example ‘getjson‘:

{
  "exec": {
    "steps": [
      {
        "name": "query",
        "module": "dbupdater",
        "action": "custom",
        "options": {
          "connection": "placexdb",
          "sql": {
            "query": "select \"rawdata\" from \"ritem\" where \"ritem_id\" = 11014",
            "params": []
          }
        },
        "output": true,
        "meta": [
          {
            "name": "rawdata",
            "type": "json"
          }
        ],
        "type": "dbcustom_query",
        "disabled": true
      }
    ]
  }
}

As I understand Wappler don’t like this "type": "json"

as i see other errors about “path”.

As I understand it, Wappler doesn't like the path parameter in the library element call step (exec). I'll say it again: everything works.

{
  "exec": {
    "steps": [
      {
        "name": "tr",
        "module": "core",
        "action": "exec",
        "options": {
          "path": "inde/ai/trans_two",
          "exec": "inde/ai/trans_two",
          "params": {
            "title": "{{src[0].title.default('')}}",
            "descr": "{{src[0].descr.default('')}}",
            "src_lang": "en",
            "trg_lang": "{{$value.lang}}"
          }
        }
      }
    ]
  }
}

This was generated using AI.

If I remove “path,” Wappler fixes the error. I think this is actually the AI's doing. So I have no complaints about Wappler here.

My question was about where Wappler gets its information on Server Actions. As I understand it, it comes from the JSON file, plus some default values that aren’t shown in the JSON but are visible in the graphical interface. I wouldn’t have created such ambiguity; everything related to server action should be clearly and concisely documented in one place. But now I’m aware of this feature of Wappler and will take it into account.

I see you have a database field of type json which you are getting through a custom query, and this causes the issue as it is not in the listed types of data in the schema options:

that's the issue here.
We will check this.

1 Like

But was it Wappler's AI Assistant which did that or are you using AI outside Wappler?

Right now I'm using ChatGPT. I tell it what to write, taught it the basics, and it generates perfectly functional JSON texts for Server Actions. At first, there were quite a few errors, so I asked it to read the latest documentation and sent it instructions on how to do it correctly several times. Now I see there’s just one remaining issue with the path parameter for core.exec. I’ll fine-tune it and remove the parameter wherever it appears. For me, this is a perfectly workable setup.

I tried using the Wappler AI assistant. The first problem is that it takes a very, very, very long time—it took 20 minutes to complete a simple task... The second problem is that it’s very expensive. In 20–30 minutes, it can easily cost $10. Repeated requests took just as long and were just as expensive (even though it would seem like it already had the content). I’ve tried ChatGPT (the most expensive), DeepSeek, and Claude. I haven’t been able to get the local LLM (vllm) set up yet—there’s an issue with the tools. I tried this about a month ago and have put the project on hold for now.

Just a suggestion. Personally, I would find it helpful to see the Server Action text in the same way as HTML, rather than just the graphical representation. Oh, I see it's there! I can open the Server Action in the code editor! Yahooo :slight_smile:

These days, I mostly work by telling ChatGPT what needs to be done, and it generates all the JSON for server actions and the HTML for the page. The result is either good or an excellent starting point that I can then refine manually. I hardly ever make any changes to the admin pages. But I’d like to automate this even further using a local LLM, so I’ll continue working on this.