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

Expose id string in SaveRuleRes #397

Closed
aseure opened this issue Jan 12, 2018 · 4 comments
Closed

Expose id string in SaveRuleRes #397

aseure opened this issue Jan 12, 2018 · 4 comments
Labels

Comments

@aseure
Copy link

aseure commented Jan 12, 2018

No description provided.

@aseure
Copy link
Author

aseure commented Apr 3, 2018

@maxiloc
Weird behaviour detected here:

  • Even though the objectID field is Required according to the documentation, I can save a rule without defining it
  • If I provide the field, I don't have the id field in the raw JSON response
  • If I don't provide it, I still do not have the id field in the raw JSON response but I get "objectID":"rules" and it's always the same, even after multiple calls.

Any idea why? Should we document the field and/or rename it? If you don't have any clue, I'll ask Search API Squad.

@maxiloc
Copy link

maxiloc commented Apr 3, 2018

The endpoint is /1/indexes/{indexName}/rules/{objectID} so objectID is should be required.

@aseure
Copy link
Author

aseure commented Apr 4, 2018

Waiting for an answer from Search API Squad, apparently it's a bug: we shouldn't be able to call this endpoint with an empty objectID.

@aseure
Copy link
Author

aseure commented Apr 4, 2018

After investigations, we have discovered that calling the Save a single rule endpoint with an empty objectID field for the rule is interpreted by the engine as a new record to index, whose objectID is rules, which maps to Add/Update an object by ID endpoint.

In other words, instead of saving a new rule with /1/indexes/{indexName}/rules/{objectID} with an empty objectID (even in the presence of the trailing slash after rules), we were actually calling /1/indexes/{indexName}/{objectID} with objectID set to rules, creating a new record instead.

As this routing issue cannot be fixed server-side, we will have to enforce it client-side, by checking that the given objectID is not empty. Same applies for all other API clients.

Thank you for helping me investigate @clement-leprovost and @Nagriar.

@maxiloc Regarding the original issue, I confirm that after a SaveRule call the expected response is only composed of the taskID/updatedAt fields, as correctly documented here (REST API) and incorrectly documented here (API method) (see https://github.com/algolia/doc/issues/1398 for the related issue in the documentation repository).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants