mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-14 07:00:01 -04:00
Enhance logging for bad PUTs with 'undefined' slug ids
This commit is contained in:
parent
70ed07e558
commit
c242317d91
1 changed files with 6 additions and 2 deletions
|
@ -348,7 +348,11 @@ module.exports = class Handler
|
|||
return @sendForbiddenError(res) if @modelClass.schema.uses_coco_versions and not req.user.isAdmin() # Campaign editor just saves over things.
|
||||
return @sendBadInputError(res, 'No input.') if _.isEmpty(req.body)
|
||||
return @sendForbiddenError(res) unless @hasAccess(req)
|
||||
@getDocumentForIdOrSlug req.body._id or id, (err, document) =>
|
||||
idOrSlug = req.body._id or id
|
||||
if not idOrSlug or idOrSlug is 'undefined'
|
||||
console.error "Bad PUT trying to fetching the slug: #{idOrSlug} for #{@modelClass.collection?.name} from #{req.headers['x-current-path']}?"
|
||||
return @sendBadInputError(res, 'No _id field provided.')
|
||||
@getDocumentForIdOrSlug idOrSlug, (err, document) =>
|
||||
return @sendBadInputError(res, 'Bad id.') if err and err.name is 'CastError'
|
||||
return @sendDatabaseError(res, err) if err
|
||||
return @sendNotFoundError(res) unless document?
|
||||
|
@ -502,7 +506,7 @@ module.exports = class Handler
|
|||
query = @modelClass.findById(idOrSlug)
|
||||
else
|
||||
if not idOrSlug or idOrSlug is 'undefined'
|
||||
console.error "What? Why are we fetching the slug: #{idOrSlug}?"
|
||||
console.error "Bad request trying to fetching the slug: #{idOrSlug} for #{@modelClass.collection?.name}"
|
||||
console.trace()
|
||||
return done null, null
|
||||
query = @modelClass.findOne {slug: idOrSlug}
|
||||
|
|
Loading…
Reference in a new issue