Revert "🐛 Fixed a 500 error for incorrect fields parameter in API"

- this reverts commit 5584430ddc until we
  can investigate why tests are failing
This commit is contained in:
Daniel Lockyer 2021-07-05 17:36:44 +01:00
parent 5584430ddc
commit 8a1fd1f57f
No known key found for this signature in database
GPG Key ID: D21186F0B47295AD
2 changed files with 2 additions and 27 deletions

View File

@ -1,10 +1,5 @@
const _ = require('lodash');
const errors = require('@tryghost/errors');
const tpl = require('@tryghost/tpl');
const messages = {
couldNotUnderstandRequest: 'Could not understand request.'
};
/**
* @param {Bookshelf} Bookshelf
@ -121,7 +116,7 @@ module.exports = function (Bookshelf) {
* @param {Object} [unfilteredOptions]
* @return {Promise<Bookshelf['Model']>} Single Model
*/
findOne: async function findOne(data, unfilteredOptions) {
findOne: function findOne(data, unfilteredOptions) {
const options = this.filterOptions(unfilteredOptions, 'findOne');
data = this.filterData(data);
const model = this.forge(data);
@ -136,19 +131,7 @@ module.exports = function (Bookshelf) {
options.columns = _.intersection(options.columns, this.prototype.permittedAttributes());
}
try {
return await model.fetch(options);
} catch (err) {
// CASE: SQL syntax is incorrect
if (err.errno === 1054 || err.errno === 1) {
throw new errors.BadRequestError({
message: tpl(messages.couldNotUnderstandRequest),
err
});
}
throw err;
}
return model.fetch(options);
},
/**

View File

@ -283,14 +283,6 @@ describe('Posts API (canary)', function () {
done();
});
});
it('throws a 400 when a non-existing field is requested', async function () {
await request.get(localUtils.API.getApiQuery(`posts/slug/${testUtils.DataGenerator.Content.posts[0].slug}/?fields=tags`))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(400);
});
});
describe('Add', function () {