Can't save API file with dynamic connections

For some time now I have been able to create dynamic DB connections using data bindings in the connection file. Since updating to 3.8.2, I cannot now edit or save any action steps in API files that have these dynamic properties. It seems that there’s some kind of validation that prevents saving and even prevents any query editors/dialog boxes/data pickers from opening, even if it is just to set a value. @jonl I know you use similar dynamic connections, have you had the same issue?

This is a HUGE issue for me - how do I get around it?

The only way I have found so far, is to set the files to the static connection I use for testing, make the changes I need, then open the API file in the code editor and then manually change the connection parameter there. This is not a sustainable way of working.

Hi Ben,

I am still on 3.7.2 as I am currently finishing a big feature branch. Once I deploy I will upgrade.

Nonetheless, I just use dynamic bindings on database connections for now so my workflow is not as impacted as yours.

When it happens I use code view and VSC so I normally just adapt my workflow until a fix is delivered.

1 Like

Cheers Jonas,
That’s the change that’s causing the issue; bindings in DB connections…
If you have any query steps in your API file that use DB with dynamic bindings, you now can’t edit or save anything in that file unless you switch it to a static connection - you can seemingly then only switch to the dynamic connection and save in code view.

Sorry.

I understand now. I thought it was related to the API action.

I don’t know what has changed since but if I check the contents for the SC file I see that the DB connection is only referenced by name.

"name": "query1",
        "module": "dbconnector",
        "action": "single",
        "options": {
          "connection": "db",

And the db file which is an external json file has the dynamic bindings so I fail to understand what relation there is between these two separate files only referenced from one json to the other by the name of it. The db connection string bindings are not inside the SC API file.

Could you explain this more in detail and add screenshots?

Ben is your problem with the connection string details or with the name of the connection itself? Are you calling the connection file dynamically?

Or is your problem related to content like this?

{
  "name": "db",
  "module": "dbconnector",
  "action": "connect",
  "options": {
    "client": "postgres",
    "connection": {
      "host": "{{$_ENV.DATABASE_HOST}}",
      "port": "{{$_ENV.DATABASE_PORT}}",
      "user": "{{$_ENV.DATABASE_USER}}",
      "password": "{{$_ENV.DATABASE_PASS}}",
      "database": "{{$_ENV.DATABASE_NAME}}"
    }
  },
  "fileName": "db.json"
}

I think there must be some new validation to SC files that checks the DB connection before saving or opening dialog boxes. My dynamic connection is as follows:

{
  "name": "dyn_connect",
  "module": "dbconnector",
  "action": "connect",
  "options": {
    "server": "mysql",
    "databaseType": "MySQL",
    "connectionString": "mysql:host={{getdbcreds.dbhost}};sslverify=true;dbname={{getdbcreds.dbname}};user={{getdbcreds.dbuser}};password={{getdbcreds.dbpass}};charset=utf8"
  }
}

coming after the query (getdbcreds) that supplies the connection parameters. I have a static connection file that I use when making any changes to queries. I then switch back to the dynamic one before saving the file.

I’m not sure what screenshots I can send you, if that connection is used in the file on any query, I cannot save the file, use data pickers or access query managers (even on queries linked to static connections)

1 Like

It’s as per your code section, when bindings are used in the connection settings.

1 Like

Are you getting any errors or so about validation?

There has been changes then as how connection json files are structured. The structure in your file and mine are totally different so I guess that with the latest changes to the db manager and how it integrates with SC, bindings case scenario was missed. I have to stay a bit longer in 3.7.2 until this is sorted out then.

I have always had an error about validation if I try to open query manager while the dyn_connect DB connection is selected which is why I have the static connection for testing.
Now, though I can’t open anything. There’s sometimes the very quickest flash of something when I try and open a dialogue but no where near quick enough to read - probably just a loading message. There’s no lasting error message.
Hopefully this video helps:

test_sch is a ‘standard’ connection with fixed host/user/password etc.
dyn_connect is the dynamic one

This project is PHP & MySql - not sure if that would account for the difference?

I can’t really see anything special, try reproducing it with the debug logging on and attach a log file here.

Restart Wappler with logging, reproduce the problem and attach the debug log. See:

Here’s the bug report

report_2021-2-8_13-8-30.zip (482.5 KB)

Is there extra validation now that checks to see if schema exists for queries that could be preventing things?

Do you have also defined a direct database connection in the database manager?
You should do so.

As it seems now database manager is trying to access your server connect connection and as it is dynamic - it can’t parse it so it fails.

So for the dynamic one, I need to enter the static details?

Wappler needs to access your database in the database manager. There a direct connection is required and you can’t/need to have dynamic data there. You just need to enter your database credentials.

For server connect itself - well that is your database connection on the server - so there you can choose to have it dynamic as you wish.

1 Like

You beauty! Thanks @George
Not only does that fix it, but it solves one of my long-standing bug bears about having to switch between static connection for testing to the dynamic one before saving.

@jonl - you now HAVE to have the Direct Database Connection set up in Database Manager to use bindings in the connection file.

I’ll be using it lots to keep testing it in the next 24 hours or so!

3 Likes

Thanks Ben. I will keep it in mind when I upgrade.

1 Like