Skip to content

500 internal server error when sending malformed If-Match #38

Description

@untitaker

When sending a PUT-request with a header like If-Match: "lolnope", reStore will return a 500 internal server error. The stacktrace acquired with #25 is:

  TypeError: Cannot read property '0' of null
    at Storage.getVersion (/home/untitaker/projects/restore/lib/controllers/storage.js:144:52)
    at null.put (/home/untitaker/projects/restore/lib/controllers/storage.js:69:22)
    at Restore.dispatch (/home/untitaker/projects/restore/lib/restore.js:139:46)
    at IncomingMessage.<anonymous> (/home/untitaker/projects/restore/lib/restore.js:82:10)
    at emitNone (events.js:67:13)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:893:12)
    at doNTCallback2 (node.js:429:9)
    at process._tickDomainCallback (node.js:384:17)

I think the best solution is to refactor reStore to compute the full etag value for the target file, and compare etags/versions as strings instead of integers. That would take care of this problem in a way that doesn't require special handling for parsing errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions