Scripting issues, primarily with Python

Hi there,

We recently upgraded to DF 2.2 and are bumping into some issues with the custom scripting.

  1. [This one was an issue in 2.1.2 as well, but we hoped the upgrade would fix it.] Requests other than HTTP GET requests don’t seem to be working for us with Python scripting. For example, I have an extremely basic custom service to test the Python scripting that just throws an exception - that’s it. The exception is only thrown on GET requests, but not other types. The same holds true for pre- and post-process scripts. When I just try to throw an exception to make sure things work on a specific table, the GET pre-process script works in Python, but it’s totally ignored if I move it to the POST pre-process script. I’ve tried more advanced scripts than just throwing an exception, but obviously that doesn’t work either. Other types of requests do, however, seem to work in the other scripting languages, including Node.js.

  2. Following up on that (this is less of an issue and more of a request), after upgrading to 2.2, Python scripting stopped working altogether. After spending some time digging through the stack trace and the source code of df-core, I was able to see that the Python scripting engine imports the “bunch” module, which wasn’t installed on our system. Installing this seems to have fixed that specific problem. Are there requirements listed on the wiki somewhere for using Python (or other scripting engines)? They’d certainly be nice to have so small things like this can be easily avoided or solved. I’m going to apologize in advance if they do exist somewhere and I just totally missed them!

  3. Small bug - if I create a new custom scripting service with no code in the “Config” tab, I then am unable to edit and save the Service in the future. For example, I create a new custom Node.js scripting service, put no code in the “Config” tab, and click save. Then, I come back to the service later, go to the “Config” tab, enter some code, and hit save, but nothing happens - no success flash message, and the service remains unchanged.

Sorry to list these all here. Please let me know if there’s anything else you need from me. Our instance details are below. Thank you!!!

DreamFactory Instance
Admin Application Version: 2.2.1
DreamFactory Version: 2.2.0
System Database: mysql

Server
Operating System: RHEL 7.2

1 Like

Hi @phooper,

Item 1: I could not duplicate the issue as you mentioned using 2.2. Everything works for me as expected. Can you walk me through the steps that you took? Maybe a screencast?

Item 2: Already updated all Python scripting related pages on the wiki to indicate ‘bunch’ package is required.

Item 3: I confirmed that this is a bug on the admin console. We will fix this.

2 Likes

Hi @aislam,

Thanks for getting back with me. I did a little more testing and the issue I’m having is a little more nuanced than just “anything but GET doesn’t work in Python scripting” like I first said. The problem seems to occur when I try to pass data in the body of a request with Python scripting. At that point, things don’t work. I did a screencast and uploaded it to Google Drive so you can see it.

https://drive.google.com/open?id=0Bz-TrSugLGAeM3ZKeloxMGp5VzA

Basically, you’ll see that we have a role with access to three services, and all the access options are checked for each. The video then goes through the following using Postman:

  1. Starts with the “math” custom scripting service in Node.js. This is the code directly from the wiki. On a GET request with nothing else in the URL (params, etc.), it’s supposed to return all options, which it does. On a POST request, it’s supposed to return that only HTTP GET is allowed, which it does when there is both content in the body and not. Everything is great here (same with PHP and V8, too).

  2. Goes on to the “math” custom scripting service in Python. Again, this code is directly from the wiki. On a GET request, it returns the options as expect. However, on a POST request with body content, the script does not raise an exception like it should saying only HTTP GET is allowed. When I strip the body content, it works like it should.

  3. Goes on to a pre-process script for a table we have in our Postgres database. I have both a GET and POST pre-process script for this table that throw some error I copied from the wiki to validate annual revenue. When I send a GET request, the exception is raised, as expected. However, when I send a POST request (again with content in the body), the pre-process script is bypassed and goes right to throwing an error about a required field. If I strip the body content, I can tell the pre-process script is run because it raises the right exception.

Maybe I’m just doing something wrong, but it’s hard to tell when other scripting languages work just fine. Please let me know what you think and what I might be able to try, or if you need anything else.

Thanks!

1 Like

@phooper, Thanks a lot for making that screencast and explaining the issue in details.

I was able to duplicate the issue. It was only happening when I made the call using POSTMAN. If I use test_rest (a simple REST client that comes with df2 at http://your-instance.com/test_rest.html) then it worked fine. I was also getting a similar error when made a GET call using a payload (not an ideal situation but still breaks the script).

I have fixed these issues in the develop branch of df-core package. This will be available in our next release. For you, this may not be an issue if you make the call from your app vs POSTMAN. But if you want you can use the develop branch of df-core by making the following change in the composer.json file.

Replace: "dreamfactory/df-core": "~0.3.0",
with: "dreamfactory/df-core": "dev-develop as dev-master",

Then run composer update to pull the develop branch. Remember, this is develop branch and if you continue to use this you may run into some other issues.

1 Like

Oh okay, great! Thanks for identifying the issue - I can certainly work around this until the next release. I appreciate your help!

1 Like