[GH-ISSUE #772] API Methods for Creating or Updating Bookmarks Do Not Accept String for createdAt field #504

Closed
opened 2026-03-02 11:50:24 +03:00 by kerem · 2 comments
Owner

Originally created by @coltoneakins on GitHub (Dec 27, 2024).
Original GitHub issue: https://github.com/karakeep-app/karakeep/issues/772

Describe the Bug

API methods such as 'Create a new bookmark' do not allow strings for date-type fields like createdAt. API reference:
https://docs.hoarder.app/api/create-a-new-bookmark

There is no coercsion on the date fields. See: https://stackoverflow.com/questions/75157299/how-can-zod-date-type-accept-iso-date-strings

Example request:

PATCH http://localhost:3000/api/v1/bookmarks/ht4h5o9t1uderpcqcl1k17hw

Body:

{
"createdAt": "2019-07-07T00:31:0.000Z"
}

Response:

{
"code": "ParseError",
"message": "createdAt: Expected date, received string"
}

This is a problem with the way dates are stored or a problem with validation on the API via zod. This effectively makes it so there is no way to import bookmarks via the API with createdAt dates.

Steps to Reproduce

  1. Set up Hoarder
  2. Attempt to use any API call for creating or updating a bookmark where you specify the createdAt field
  3. Notice that the API always responds with a ParseError

Expected Behaviour

API methods can accept strings for date fields. This is proper JSON. 'date' data types are not valid JSON sent over the wire---so, they must be sent as strings.

Screenshots or Additional Context

api-date-string-bug

Device Details

No response

Exact Hoarder Version

v0.20.0

Originally created by @coltoneakins on GitHub (Dec 27, 2024). Original GitHub issue: https://github.com/karakeep-app/karakeep/issues/772 ### Describe the Bug API methods such as 'Create a new bookmark' do not allow strings for date-type fields like createdAt. API reference: https://docs.hoarder.app/api/create-a-new-bookmark There is no coercsion on the date fields. See: https://stackoverflow.com/questions/75157299/how-can-zod-date-type-accept-iso-date-strings Example request: PATCH http://localhost:3000/api/v1/bookmarks/ht4h5o9t1uderpcqcl1k17hw Body: { "createdAt": "2019-07-07T00:31:0.000Z" } Response: { "code": "ParseError", "message": "createdAt: Expected date, received string" } This is a problem with the way dates are stored or a problem with validation on the API via zod. This effectively makes it so there is no way to import bookmarks via the API with createdAt dates. ### Steps to Reproduce 1. Set up Hoarder 2. Attempt to use any API call for creating or updating a bookmark where you specify the createdAt field 3. Notice that the API always responds with a ParseError ### Expected Behaviour API methods can accept strings for date fields. This is proper JSON. 'date' data types are not valid JSON sent over the wire---so, they must be sent as strings. ### Screenshots or Additional Context ![api-date-string-bug](https://github.com/user-attachments/assets/72083168-e993-46b3-ade2-3fd7c1a45169) ### Device Details _No response_ ### Exact Hoarder Version v0.20.0
kerem 2026-03-02 11:50:24 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@MohamedBassem commented on GitHub (Dec 27, 2024):

Yeah, those dates should have had a coerce indeed. I can send a fix.

<!-- gh-comment-id:2563831149 --> @MohamedBassem commented on GitHub (Dec 27, 2024): Yeah, those dates should have had a coerce indeed. I can send a fix.
Author
Owner

@MohamedBassem commented on GitHub (Dec 28, 2024):

Fixed in a1a3a7e. Thanks for the report!

<!-- gh-comment-id:2564403472 --> @MohamedBassem commented on GitHub (Dec 28, 2024): Fixed in a1a3a7e. Thanks for the report!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/karakeep#504
No description provided.