Adding a new query runner, I have a data source field that won't save


#1

I’m trying to add ActiveData as a query_runner. This is where I’m at: https://github.com/mozilla/redash/compare/master...alison985:83_activedata_query_runner The problem is that it won’t save the Host URL field (which is required) on the data source configuration page no matter what I do. I have no idea why. The form is generated by the dynamic-form.html page and the configuration in the activedata.py file matches the syntax and attributes of other query_runner configs. Thoughts?


#2

I copied activedata.py into my environment, created new data source from it and it saved everything properly.

Can you make sure that other data source types do save properly in your environment?


#3

Interestingly enough saving other data sources has stopped working. Have you seen this before? How do you fix it?


#4

Didn’t see this before.

If the data source doesn’t get saved at all, then check the server logs. Otherwise, just compare your current state of the code with the latest stable version you have (master branch?) and try to see what’s changed.


#5

Thanks Arik. I did the comparison to see what changed in the link provided above ( https://github.com/mozilla/redash/compare/master...alison985:83_activedata_query_runner ).

Upon digging deeper, I have found that it is saving the values to the redash database, but it does not display the saved information back to the user making it seem like something has failed. It appears to be doing the same for other, working data sources. Is that a security feature or known issue?


#6

It’s neither. The only values we don’t show after saving are the ones that are marked as secret, but this is not the case.

Maybe this functionality is broken in your master branch as well?


#7

alison,

Revert you code and see if the problem persists; it may be a problem in the state of the various Redash services, but I am guessing.


#8

HTML is always changing on me: It may be these lines

     <input name="input" type="{{field.property.type}}" class="form-control" ng-model="target.options[field.name]" ng-required="field.property.required"
            ng-if="field.property.type !== 'file' && field.property.type !== 'checkbox'" accesskey="tab" placeholder="{{field.property.default}}">
           <div class="mute-text"> {{ field.property.info }} </div>

The <input> does not end in />. Could it be messing with all following tags?


#9

@klahnakoski All of the other input tags in the project lack the ending /, so I was not adding it to maintain consistency but I tried it for kicks and giggles and it doesn’t change anything.

I had hypothesized the same conclusion @arikfr had about the mozilla master branch just being broken, so I had tried reverting all commits I made to the mozilla/redash master branch ever (including a rebase from getredash/redash master the week of June 12) but that had no effect on, for instance, postgres data source connections displaying saved data source info. So then I went forward and tried the branch I have that does a merge from getredash/redash master (https://github.com/mozilla/redash/pull/105) last week and that doesn’t show saved data source values either. I also tried a visual comparison of getredash/redash master dynamic-form.html and dynamic-form.js files with my dev branch for this ticket and found no differences that seemed relevant. (There is an improvement to error handling on the save of the form but it doesn’t change the behavior in that branch.)

Now, since the values are saving, but not displaying after save, I played around with the ng-model="target.options[field.name]" in the input tag, since it would seem the Angular data bind to the field is at least a logical place to look. Also, it refers to target.options instead of field.property.x like the rest of the Angular references. I tried field.name and a few other things mostly for kicks but they didn’t work.

I also tried a different __init__() function (commit is synced to my dev branch if you’re interested) that mirrors the same function in other query_runners to no effect.

Since the removal of information occurs after the save I also tried commenting out $scope.dataSourceForm.$setPristine(); on line 132 of dynamic-form.js (even though it should only be changing CSS classes in the form), and that didn’t work.

Then, since the doc_url field is working fine and the difference between it and the host_url field are that host_url is required, I commented out the “required” line for the host_url field in the configuration_schema and that didn’t help.

Having read dynamic-form.js, @arikfr, it seems most concerned with the type of form field (i.e. checkbox, file, etc.). Could you please point out to me where it’s pulling the saved information from the database to assign it to target.options[field.name]?


#10

so, given that master also has this problem, I am guessing your setup is corrupted. I suggest deploying a fresh redash instance.


#11

From the phrasing I’m not sure – was it working properly or not?

Also, on your production system, can you save and reload data sources properly?

target is an object the DynamicForm component receives from its parent. It’s being loaded here.

I would try reverting any changes to dynamic_form.{js,html} files and to pages/data-sources/show.{js,html} files. If reverting resolves the issue, then review all changes and see what might have causes it.

Actually before that make sure the data sources controller or model code in the backend didn’t change either.


#12

Found it. It was a change to the model from November. https://github.com/mozilla/redash/commit/e259805da42c400b6384a840426643cfd4d764a1#diff-2eb9bad8b59774e58b2c9a664440905aR460


#13

:clap: glad you figured it out :slight_smile: