API returns error when Note lacks attachment #9024
Labels
Area: API
Issues & PRs related to all things regarding the API
Priority:Important
Issues & PRs that are important; broken functions, errors - there are workarounds
Type: Bug
Bugs within the core SuiteCRM codebase
API returns error when Note lacks attachment
Issue
When doing a Patch of a Note record - if your client has the
filename
attribute present, then the application assumes that you're trying to upload a file. It assumes this even if thefilename
is empty. An empty attribute causes the endpoint to throw an exception and return an error to the client.When you
GET
a Note bean, it returns thefilename
attribute as an empty string (if there is no file). It is not uncommon for a client to return that same object for aPATCH
- so the application should not fail if this attribute is blank.This is not a special field type - it should probably not be the trigger to initiate an upload and it certainly should accept blank values.
Error introduced by #8408
Expected Behavior
If you
PATCH
a Note with a blankfilename
, the request should not fail.Actual Behavior
If you
PATCH
a Note with a blankfilename
, the application tries to do a file upload and fails when it cannot interpret the filename.Examples:
GET a Note:
If your client edits the description and tries to pass the object back to the API, it will fail
Response:
Possible Fix
At a minimum, line
378
in ModuleService.php should have a!empty()
condition addedSteps to Reproduce
filename
as a blank stringContext
Our mobile app builds objects based on vardefs. It uses these objects when communicating with the API. It's unable to edit Notes that do not have attachments because Suite won't accept a blank
filename
Your Environment
The text was updated successfully, but these errors were encountered: