Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for updating multiple tags with one request. #130

Closed
Stason1o opened this issue May 30, 2023 · 12 comments
Closed

Support for updating multiple tags with one request. #130

Stason1o opened this issue May 30, 2023 · 12 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request
Milestone

Comments

@Stason1o
Copy link

Stason1o commented May 30, 2023

Recently changes where introduced for POST /documents/{documentId}/tags, to support adding List of tags.
I would like to suggest adding same support for updating multiple document tags in one request for
PUT /documents/{documentId}/tags/{tagKey}

@Stason1o Stason1o changed the title Support of updating multiple tags with one request. Support for updating multiple tags with one request. May 30, 2023
@RyanBuhrWA
Copy link

See if the PATCH /documents/{documentId} API will solve this for you. It allows you to send an array of tags to a document and add or update all of them. Here's the documentation for it: Update Document API reference

@mfriesen mfriesen added the enhancement New feature or request label Jun 1, 2023
@Stason1o
Copy link
Author

Stason1o commented Jun 2, 2023

@RyanBuhrWA , didn't see that functionality, was looking specifically on DocumentTags endpoints. I will try your suggestion today to see if it works fine for me and will come back with details later. Thanks!

@mfriesen
Copy link
Member

mfriesen commented Jun 2, 2023

@Stason1o We will add this to our roadmap.

@Stason1o
Copy link
Author

Stason1o commented Jun 5, 2023

So, follow up to workaround @RyanBuhrWA mentioned with patch endpoint. I tried to send a payload, having only list of tags supplied, without content, and then, all getDocumentContent requests are failing with 500, but I couldn't find logs for the root cause of this( limited access to company CloudWatch) so, I guess this does not fit my case(unless I get access to CW and investigate logs).
Supplying everytime content could be resource heavy, having in mind that documents could be huge size, and rewriting same content everytime tags are updated is also not a good solution..
But anyway, thanks for helping!

Will stick to current implementation - looping through tags and calling PUT document tag one by one, until new endpoint is released

@mfriesen
Copy link
Member

mfriesen commented Jun 5, 2023

@Stason1o Can you provide the request you sent using PATCH /documents/{documentId} and we can look into the 500 error you are seeing.

@Stason1o
Copy link
Author

Stason1o commented Jun 6, 2023

@mfriesen Hi,
So basically the steps I am performing with document:

  1. Create document: POST: /documents with valid body - 200 Response
  2. Update Document, 2 steps:

Adding New tags( if they don't exist on document yet) using POST: /documents/{documentId}/tags
Updating Existing ones, using PATCH: /documents/{documentId}, with payload and getting 200 Response:

{
"tags": [
 {
    "key": "string",
    "value":"string",
 },
 {
    "key2": "string",
    "value2":"string",
 }
]

I am not supplying content for this request, because I don't have it fetched at that moment from Formkiq. Sending content as a part of this request will require addiitional GetDocumentContent, which is "redundand" for me, because I am working with tags only at that moment.

  1. Trying to get documentContent and this fails with 500 Response, indicating url, I was calling (could be our custom error response)

If I call GetDocumentContent before calling Patch Document, I receive 200 Response and document content. After calling Patch Document, and then GetDocumentContent - I get 500 response.
I suppose, that after calling Patch Document without supplying content in request body, FormKiq will set is as null? and this is causing issues on GetDocumentContent?

@mfriesen
Copy link
Member

mfriesen commented Jun 16, 2023

Recently changes where introduced for POST /documents/{documentId}/tags, to support adding List of tags. I would like to suggest adding same support for updating multiple document tags in one request for PUT /documents/{documentId}/tags/{tagKey}

@Stason1o I assume you mean to add a PUT /documents/{documentId}/tags instead of /documents/{documentId}/tags/{tagKey}
with a body of
{
"tags": [ ... ]
}

which would replace all the tags in a document?

@mfriesen mfriesen self-assigned this Jun 16, 2023
@mfriesen mfriesen added this to the v1.12.0 milestone Jun 16, 2023
@mfriesen mfriesen added the bug Something isn't working label Jun 16, 2023
@Stason1o
Copy link
Author

@mfriesen, so basically I need an endpoint, which will accept body
{
"tags": []
}
and for each tag from request body, if this tag exists on document, its value will be updated to the value from request body.

Scenario:

  1. I have created a document with tags:[ id, type(img), subtype(nature)]
  2. I want to add additional tags to it. I use endpoint POST /documents/{documentId}/tags with body,
    containig new tags:
    {
    "tags": [case, comment, description, status(in_validation)]
    }. In result now document has list of tags:[id, type(img), subtype(nature), case, comment, description, status]
  3. Now I want to update some of the tags - type(png), subtype(city).
    With current version, I need to use PUT/documents/{documentId}/tags/{tagKey} and make a call for each tag I want to update and supply new value/values
    Feature request - have an endpoint which accepts tags:[] and updates exising tags with supplied value/values
    like PUT/PATCH /documents/{documentId}/tags
    {
    tags:[type(png), subtype(city)]
    }
    so I will make one request for updating multiple tag values at once, instead of calling formkiq service 20-30 times, depending on how many tags I need to update

Result - document tags are updated and document has tags:[id, type(png), subtype(city), case, comment, description, status]

@mfriesen
Copy link
Member

GetDocumentContent - I get 500 response. I suppose, that after calling Patch Document without supplying content in request body, FormKiq will set is as null? and this is causing issues on GetDocumentContent?

@Stason1o
Unfortunately I have been unable to duplicate the 500 issue you are experiencing. Would it be possible for you to look at the CloudWatch logs for the "DocumentsApi" lambda for a stack trace of the error you can send to me?

@Stason1o
Copy link
Author

Stason1o commented Jun 17, 2023

@mfriesen So, I tried this morning and got same results.
Steps I performed:

  1. Create a document with child document POST: /documents
    addDocumentPayload.txt

Note: At this point GET /documents/{documentId} and GET /documents/{documentId}/content are working as expected.

  1. Update document tags(metadata), by calling update document endpoint PATCH /documents/{documentId}, by adding 4 new tags and 1 existing tag with body: { tags: [] }

updateDocumentPayload.txt

Response is 200.

  1. Perform call to GET /documents/{documentId}/content
    expected: 200 and content
    actual - 500 error:

logs.txt

@mfriesen
Copy link
Member

@Stason1o Thank you so much for the details. I'm still not able to replicate the issue.

Which version of FormKiQ are you using? From the logs, it looks like you are on v1.8.9?

@Stason1o
Copy link
Author

@mfriesen Yeah, it's 1.8.X (not sure about minor version), we will be migrating to newer version as soon as v1.12 will be out =)
Anyway, thanks for help.

mfriesen added a commit that referenced this issue Jul 22, 2023
* updated library dependencies / gradle

* replaced @ReflectableImport with graalvm annotationProcessor

* #130 added PUT/PATCH /documents/{documentId}/tags

* 138 post documents with reservered tag keys (#141)

* updated localstack from 0.12.2 to 2.1

* #138 - POST /documents with reservered tag keys

* #139 - Add permissions to documents POST / PATCH /documents/{documentId}

* updated to aws-cognito 1.5.1

* change Folder 'indexKey' to not be UrlEncoded.

* added ApiAuthorizationInterceptor

* added GET / POST / DELETE /folders

* added ApiRequestHandlerResponseInterceptor

* added FolderIndexRecord

* added interceptor before request is processed

* FolderIndexProcessor: added getFoldersByDocumentId
mfriesen added a commit that referenced this issue Aug 14, 2023
* #130 - Feature: Added PUT/PATCH /documents/{documentId}/tags to allow adding/updating multiple tags to a document at once

* #131 - Feature: Added POST /documents/compress to create a ZIP file of multiple document's contents.

* #133 - Feature: Added PATCH /documents/tags to allow adding tags to documents based on tag search criteria

* #138 - Bug: Added validation for reservered tag keys when using POST /documents

* #144 - Bug: DELETE /indices/folder return 500 when invalid siteId is used

* #145 - Feature: Added Typesense support to API GET documents/{id}/fulltext

* #150 - Bug: Renamed module 'fulltext' to 'opensearch'

* #151 - Bug: Documentation for POST /documents/upload, missing contentLength

* #158 - Bug: Improved Actions API validation

* #159 - Feature: API Keys added READ / WRITE / DELETE permissions

* #161 - Bug: POST /documents/upload generates incorrect URL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants