[Koha-bugs] [Bug 29157] New: REST API - cannot update patron & leave date_of_birth null

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Sat Oct 2 01:03:05 CEST 2021


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157

            Bug ID: 29157
           Summary: REST API - cannot update patron & leave date_of_birth
                    null
 Change sponsored?: ---
           Product: Koha
           Version: 21.05
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P5 - low
         Component: REST API
          Assignee: koha-bugs at lists.koha-community.org
          Reporter: ephetteplace at cca.edu

Created attachment 125644
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=125644&action=edit
diff of patron record after REST PUT action

I noticed when trying to update patrons with a Python script that Koha set
everyone's birthday to the current date. For each patron, I sent a Python dict
where patron['date_of_birth'] was None (Python's null value). I can send an ISO
8601 date and DOB updates appropriately but I cannot find a way to leave the
date empty, which is desirable (we don't care about age). Here's what I tried:

date_of_birth = '' (empty string)
date_of_birth = "null"
date_of_birth = "undef"

All these receive the same formatting error response:
400 Response
{'errors': [{'message': '/anyOf/0 Does not match date format.', 'path':
'/body/date_of_birth'}], 'status': 400}

As I said, setting birthdate to None (which translates to `null` in JSON)
updates the DOB to the current date, which I don't think makes sense since it's
a nullable field in the database. I'll attach a diff of a minimal test patron
where I added a "1" to their cardnumber and did nothing else. The steps were:

- create a minimal patron record (e.g. with email, userid, names)
- HTTP GET $API/patrons/username=$USERNAME
(I did not test HTTP GET $API/patrons/$BORROWERNUMBER but I assume it works the
same)
- update cardnumber e.g. patron['cardnumber'] = patron['cardnumber'] + 1
- PUT $API/patrons/$BORROWERNUMBER with json=patron

A few fields other than cardnumber changed. Both last_seen and updated_on make
sense, I find it odd date_renewed was set to the current date since I was not
renewing the patron but that's at least not problematic in our use case. It's
the DOB I'd like to avoid updating, though.

Let me know if I can provide more example data.

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.


More information about the Koha-bugs mailing list