Skip to content

Commit

Permalink
fixes error creating a new database due to Malformed JSON error for e…
Browse files Browse the repository at this point in the history
…mpty Secure extras field (apache#8630)

* handle empty encrypted_extra field

* move $("#encrypted_extra").val() to const

* handle empty extra field
  • Loading branch information
maxmelnick authored and mistercrunch committed Nov 23, 2019
1 parent b34c9d3 commit 6c83c64
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions superset/templates/superset/models/database/macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@
});

var data = {};
const extra = $("#extra").val();
const encryptedExtra = $("#encrypted_extra").val();
try{
data = JSON.stringify({
uri: $.trim($("#sqlalchemy_uri").val()),
name: $('#database_name').val(),
impersonate_user: $('#impersonate_user').is(':checked'),
extras: JSON.parse($("#extra").val()),
encrypted_extra: JSON.parse($("#encrypted_extra").val()),
extras: extra ? JSON.parse(extra) : {},
encrypted_extra: encryptedExtra ? JSON.parse(encryptedExtra) : {},
})
} catch(parse_error){
alert("Malformed JSON in the extras field: " + parse_error);
Expand Down

0 comments on commit 6c83c64

Please sign in to comment.