Delete falsey project creds before POST|PATCH

Depending on the permissions of the user submitting the form, the API
might throw an unexpected error if our creation request has a
zero-length string as its credential field. As a work-around,
normalize falsey credential fields by deleting them.
This commit is contained in:
Jake McDermott 2020-02-26 13:40:26 -05:00
parent bd30951a4f
commit 6536f5a453
No known key found for this signature in database
GPG Key ID: 0E56ED990CDFCB4F
2 changed files with 14 additions and 0 deletions

View File

@ -13,6 +13,13 @@ function ProjectAdd() {
if (values.scm_type === 'manual') {
values.scm_type = '';
}
if (!values.credential) {
// Depending on the permissions of the user submitting the form,
// the API might throw an unexpected error if our creation request
// has a zero-length string as its credential field. As a work-around,
// normalize falsey credential fields by deleting them.
delete values.credential;
}
setFormSubmitError(null);
try {
const {

View File

@ -13,6 +13,13 @@ function ProjectEdit({ project }) {
if (values.scm_type === 'manual') {
values.scm_type = '';
}
if (!values.credential) {
// Depending on the permissions of the user submitting the form,
// the API might throw an unexpected error if our creation request
// has a zero-length string as its credential field. As a work-around,
// normalize falsey credential fields by deleting them.
delete values.credential;
}
try {
const {
data: { id },