Skip to content

Commit

Permalink
fix: return 400 on invalid JSON instead of 404 (#1897)
Browse files Browse the repository at this point in the history
  • Loading branch information
olav committed Aug 8, 2022
1 parent d4b9ca4 commit df910cc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/services/openapi-service.ts
Expand Up @@ -59,7 +59,7 @@ export class OpenApiService {
validation: err.validationErrors,
});
} else {
next();
next(err);
}
});
}
Expand Down
9 changes: 9 additions & 0 deletions src/test/e2e/api/admin/feature.e2e.test.ts
Expand Up @@ -340,6 +340,15 @@ test('require new feature toggle to have a name', async () => {
.expect(400);
});

test('should return 400 on invalid JSON data', async () => {
expect.assertions(0);
return app.request
.post('/api/admin/features')
.send(`{ invalid-json }`)
.set('Content-Type', 'application/json')
.expect(400);
});

test('can not change status of feature toggle that does not exist', async () => {
expect.assertions(0);
return app.request
Expand Down

0 comments on commit df910cc

Please sign in to comment.