Saved object update w/ upsert doesn't work for multi-namespace objects that don't exist #114918
Labels
bug
Fixes for quality problems that affect the customer experience
Feature:Security/Sharing Saved Objects
Platform Security - Sharing Saved Objects feature
Team:Core
Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Team:Security
Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more!
Kibana version: 7.14+
Describe the bug:
I uncovered this while troubleshooting some bugs in #114620. That PR changes the
visualization
saved object to usenamespaceType: 'multiple-isolated'
(to become share-capable). In the process, an API integration test started failing:kibana/test/api_integration/apis/saved_objects/update.ts
Lines 105 to 117 in 7917e3c
This first assertion failed with a 404 error. Digging into it, I realized that it's because the upsert handling in the SavedObjectsRepository (SOR) is flawed:
kibana/src/core/server/saved_objects/service/lib/repository.ts
Lines 1211 to 1240 in d822d6d
Usage of the
preflightCheckIncludesNamespace
method was added before the upsert functionality. That will throw a 404 error if the object doesn't exist in the current space. So if you try to use upsert for an object that doesn't exist, it will always fail with a 404 error.Steps to reproduce:
Use #114620 and observe the failing integration test.
Expected behavior:
If upsert is NOT used:
If upsert IS used:
The text was updated successfully, but these errors were encountered: