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

Public SavedObjectsClient.resolve fails for "aliasMatch" outcome #113160

Closed
jportner opened this issue Sep 27, 2021 · 1 comment · Fixed by #113188
Closed

Public SavedObjectsClient.resolve fails for "aliasMatch" outcome #113160

jportner opened this issue Sep 27, 2021 · 1 comment · Fixed by #113188
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Feature:Security/Sharing Saved Objects Platform Security - Sharing Saved Objects feature impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more!

Comments

@jportner
Copy link
Contributor

jportner commented Sep 27, 2021

Kibana version: 7.16 (unreleased)

Describe the bug:

Starting in #112025, the public SavedObjectsClient (SOC) batches individual resolve requests into a single bulkResolve.
This works well for regular "exactMatch" outcomes".

However, if a saved object resolves with an "aliasMatch" outcome, then the SOC treats the object as not found and runs into an error.

Steps to reproduce:

  1. Start Kibana
  2. Add the "Flights" sample data
  3. Using Kibana Dev Tools, add this staging data:
    POST .kibana/_bulk
    {"index":{"_id":"test1:index-pattern:d3d7af60-4c81-11e8-b3d7-01146121b73d-test1"}}
    {"index-pattern":{"fieldFormatMap":"{\"hour_of_day\":{\"id\":\"number\",\"params\":{\"pattern\":\"00\"}},\"AvgTicketPrice\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.[00]\"}}}","runtimeFieldMap":"{\"hour_of_day\":{\"type\":\"long\",\"script\":{\"source\":\"emit(doc['timestamp'].value.getHour());\"}}}","timeFieldName":"timestamp","title":"kibana_sample_data_flights"},"coreMigrationVersion":"8.0.0","migrationVersion":{"index-pattern":"7.11.0"},"references":[],"type":"index-pattern","updated_at":"2021-09-21T10:55:48.482Z","namespace":"test1"}
    {"index":{"_id":"test2:index-pattern:d3d7af60-4c81-11e8-b3d7-01146121b73d-test2-newId"}}
    {"index-pattern":{"fieldFormatMap":"{\"hour_of_day\":{\"id\":\"number\",\"params\":{\"pattern\":\"00\"}},\"AvgTicketPrice\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.[00]\"}}}","runtimeFieldMap":"{\"hour_of_day\":{\"type\":\"long\",\"script\":{\"source\":\"emit(doc['timestamp'].value.getHour());\"}}}","timeFieldName":"timestamp","title":"kibana_sample_data_flights"},"coreMigrationVersion":"8.0.0","migrationVersion":{"index-pattern":"7.11.0"},"references":[],"type":"index-pattern","updated_at":"2021-09-21T10:55:48.482Z","namespace":"test2"}
    {"index":{"_id":"test3:index-pattern:d3d7af60-4c81-11e8-b3d7-01146121b73d-test3"}}
    {"index-pattern":{"fieldFormatMap":"{\"hour_of_day\":{\"id\":\"number\",\"params\":{\"pattern\":\"00\"}},\"AvgTicketPrice\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.[00]\"}}}","runtimeFieldMap":"{\"hour_of_day\":{\"type\":\"long\",\"script\":{\"source\":\"emit(doc['timestamp'].value.getHour());\"}}}","timeFieldName":"timestamp","title":"kibana_sample_data_flights"},"coreMigrationVersion":"8.0.0","migrationVersion":{"index-pattern":"7.11.0"},"references":[],"type":"index-pattern","updated_at":"2021-09-21T10:55:48.482Z","namespace":"test3"}
    {"index":{"_id":"test3:index-pattern:d3d7af60-4c81-11e8-b3d7-01146121b73d-test3-newId"}}
    {"index-pattern":{"fieldFormatMap":"{\"hour_of_day\":{\"id\":\"number\",\"params\":{\"pattern\":\"00\"}},\"AvgTicketPrice\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.[00]\"}}}","runtimeFieldMap":"{\"hour_of_day\":{\"type\":\"long\",\"script\":{\"source\":\"emit(doc['timestamp'].value.getHour());\"}}}","timeFieldName":"timestamp","title":"kibana_sample_data_flights"},"coreMigrationVersion":"8.0.0","migrationVersion":{"index-pattern":"7.11.0"},"references":[],"type":"index-pattern","updated_at":"2021-09-21T10:55:48.482Z","namespace":"test3"}
    {"index":{"_id":"legacy-url-alias:test2:index-pattern:d3d7af60-4c81-11e8-b3d7-01146121b73d-test2"}}
    {"legacy-url-alias":{"targetNamespace":"test2","targetType":"index-pattern","targetId":"d3d7af60-4c81-11e8-b3d7-01146121b73d-test2-newId","sourceId":"d3d7af60-4c81-11e8-b3d7-01146121b73d-test2"},"type":"legacy-url-alias","references":[]}
    {"index":{"_id":"legacy-url-alias:test3:index-pattern:d3d7af60-4c81-11e8-b3d7-01146121b73d-test3"}}
    {"legacy-url-alias":{"targetNamespace":"test3","targetType":"index-pattern","targetId":"d3d7af60-4c81-11e8-b3d7-01146121b73d-test3-newId","sourceId":"d3d7af60-4c81-11e8-b3d7-01146121b73d-test3"},"type":"legacy-url-alias","references":[]}
    {"index":{"_id":"lens:725a2be0-1ace-11ec-acee-9f628a4e2e5b-test1"}}
    {"lens":{"description":"","state":{"datasourceStates":{"indexpattern":{"layers":{"dde73e35-b62d-4900-9f81-072dcd82f2e8":{"columnOrder":["628dfb9c-50dd-4c07-80e3-a00b2a526b88","cf81f58a-ebb1-43f9-a202-9cfe5ad07bd6"],"columns":{"628dfb9c-50dd-4c07-80e3-a00b2a526b88":{"dataType":"date","isBucketed":true,"label":"timestamp","operationType":"date_histogram","params":{"interval":"auto"},"scale":"interval","sourceField":"timestamp"},"cf81f58a-ebb1-43f9-a202-9cfe5ad07bd6":{"dataType":"number","isBucketed":false,"label":"Count of records","operationType":"count","scale":"ratio","sourceField":"Records"}},"incompleteColumns":{}}}}},"filters":[],"query":{"language":"kuery","query":""},"visualization":{"axisTitlesVisibilitySettings":{"x":true,"yLeft":true,"yRight":true},"fittingFunction":"None","gridlinesVisibilitySettings":{"x":true,"yLeft":true,"yRight":true},"labelsOrientation":{"x":0,"yLeft":0,"yRight":0},"layers":[{"accessors":["cf81f58a-ebb1-43f9-a202-9cfe5ad07bd6"],"layerId":"dde73e35-b62d-4900-9f81-072dcd82f2e8","layerType":"data","position":"top","seriesType":"bar_stacked","showGridlines":false,"xAccessor":"628dfb9c-50dd-4c07-80e3-a00b2a526b88"}],"legend":{"isVisible":true,"position":"right"},"preferredSeriesType":"bar_stacked","tickLabelsVisibilitySettings":{"x":true,"yLeft":true,"yRight":true},"valueLabels":"hide","yLeftExtent":{"mode":"full"},"yRightExtent":{"mode":"full"}}},"title":"Lens","visualizationType":"lnsXY"},"coreMigrationVersion":"8.0.0","migrationVersion":{"lens":"8.0.0"},"references":[{"id":"d3d7af60-4c81-11e8-b3d7-01146121b73d-test1","name":"indexpattern-datasource-current-indexpattern","type":"index-pattern"},{"id":"d3d7af60-4c81-11e8-b3d7-01146121b73d-test1","name":"indexpattern-datasource-layer-dde73e35-b62d-4900-9f81-072dcd82f2e8","type":"index-pattern"}],"type":"lens","updated_at":"2021-09-21T11:24:12.577Z","namespaces":["test1"]}
    {"index":{"_id":"lens:725a2be0-1ace-11ec-acee-9f628a4e2e5b-test2-newId"}}
    {"lens":{"description":"","state":{"datasourceStates":{"indexpattern":{"layers":{"dde73e35-b62d-4900-9f81-072dcd82f2e8":{"columnOrder":["628dfb9c-50dd-4c07-80e3-a00b2a526b88","cf81f58a-ebb1-43f9-a202-9cfe5ad07bd6"],"columns":{"628dfb9c-50dd-4c07-80e3-a00b2a526b88":{"dataType":"date","isBucketed":true,"label":"timestamp","operationType":"date_histogram","params":{"interval":"auto"},"scale":"interval","sourceField":"timestamp"},"cf81f58a-ebb1-43f9-a202-9cfe5ad07bd6":{"dataType":"number","isBucketed":false,"label":"Count of records","operationType":"count","scale":"ratio","sourceField":"Records"}},"incompleteColumns":{}}}}},"filters":[],"query":{"language":"kuery","query":""},"visualization":{"axisTitlesVisibilitySettings":{"x":true,"yLeft":true,"yRight":true},"fittingFunction":"None","gridlinesVisibilitySettings":{"x":true,"yLeft":true,"yRight":true},"labelsOrientation":{"x":0,"yLeft":0,"yRight":0},"layers":[{"accessors":["cf81f58a-ebb1-43f9-a202-9cfe5ad07bd6"],"layerId":"dde73e35-b62d-4900-9f81-072dcd82f2e8","layerType":"data","position":"top","seriesType":"bar_stacked","showGridlines":false,"xAccessor":"628dfb9c-50dd-4c07-80e3-a00b2a526b88"}],"legend":{"isVisible":true,"position":"right"},"preferredSeriesType":"bar_stacked","tickLabelsVisibilitySettings":{"x":true,"yLeft":true,"yRight":true},"valueLabels":"hide","yLeftExtent":{"mode":"full"},"yRightExtent":{"mode":"full"}}},"title":"Lens","visualizationType":"lnsXY"},"coreMigrationVersion":"8.0.0","migrationVersion":{"lens":"8.0.0"},"references":[{"id":"d3d7af60-4c81-11e8-b3d7-01146121b73d-test2-newId","name":"indexpattern-datasource-current-indexpattern","type":"index-pattern"},{"id":"d3d7af60-4c81-11e8-b3d7-01146121b73d-test2-newId","name":"indexpattern-datasource-layer-dde73e35-b62d-4900-9f81-072dcd82f2e8","type":"index-pattern"}],"type":"lens","updated_at":"2021-09-21T11:24:12.577Z","namespaces":["test2"]}
    {"index":{"_id":"lens:725a2be0-1ace-11ec-acee-9f628a4e2e5b-test3"}}
    {"lens":{"description":"","state":{"datasourceStates":{"indexpattern":{"layers":{"dde73e35-b62d-4900-9f81-072dcd82f2e8":{"columnOrder":["628dfb9c-50dd-4c07-80e3-a00b2a526b88","cf81f58a-ebb1-43f9-a202-9cfe5ad07bd6"],"columns":{"628dfb9c-50dd-4c07-80e3-a00b2a526b88":{"dataType":"date","isBucketed":true,"label":"timestamp","operationType":"date_histogram","params":{"interval":"auto"},"scale":"interval","sourceField":"timestamp"},"cf81f58a-ebb1-43f9-a202-9cfe5ad07bd6":{"dataType":"number","isBucketed":false,"label":"Count of records","operationType":"count","scale":"ratio","sourceField":"Records"}},"incompleteColumns":{}}}}},"filters":[],"query":{"language":"kuery","query":""},"visualization":{"axisTitlesVisibilitySettings":{"x":true,"yLeft":true,"yRight":true},"fittingFunction":"None","gridlinesVisibilitySettings":{"x":true,"yLeft":true,"yRight":true},"labelsOrientation":{"x":0,"yLeft":0,"yRight":0},"layers":[{"accessors":["cf81f58a-ebb1-43f9-a202-9cfe5ad07bd6"],"layerId":"dde73e35-b62d-4900-9f81-072dcd82f2e8","layerType":"data","position":"top","seriesType":"bar_stacked","showGridlines":false,"xAccessor":"628dfb9c-50dd-4c07-80e3-a00b2a526b88"}],"legend":{"isVisible":true,"position":"right"},"preferredSeriesType":"bar_stacked","tickLabelsVisibilitySettings":{"x":true,"yLeft":true,"yRight":true},"valueLabels":"hide","yLeftExtent":{"mode":"full"},"yRightExtent":{"mode":"full"}}},"title":"Lens","visualizationType":"lnsXY"},"coreMigrationVersion":"8.0.0","migrationVersion":{"lens":"8.0.0"},"references":[{"id":"d3d7af60-4c81-11e8-b3d7-01146121b73d-test3","name":"indexpattern-datasource-current-indexpattern","type":"index-pattern"},{"id":"d3d7af60-4c81-11e8-b3d7-01146121b73d-test3","name":"indexpattern-datasource-layer-dde73e35-b62d-4900-9f81-072dcd82f2e8","type":"index-pattern"}],"type":"lens","updated_at":"2021-09-21T11:24:12.577Z","namespaces":["test3"]}
    {"index":{"_id":"lens:725a2be0-1ace-11ec-acee-9f628a4e2e5b-test3-newId"}}
    {"lens":{"description":"","state":{"datasourceStates":{"indexpattern":{"layers":{"dde73e35-b62d-4900-9f81-072dcd82f2e8":{"columnOrder":["628dfb9c-50dd-4c07-80e3-a00b2a526b88","cf81f58a-ebb1-43f9-a202-9cfe5ad07bd6"],"columns":{"628dfb9c-50dd-4c07-80e3-a00b2a526b88":{"dataType":"date","isBucketed":true,"label":"timestamp","operationType":"date_histogram","params":{"interval":"auto"},"scale":"interval","sourceField":"timestamp"},"cf81f58a-ebb1-43f9-a202-9cfe5ad07bd6":{"dataType":"number","isBucketed":false,"label":"Count of records","operationType":"count","scale":"ratio","sourceField":"Records"}},"incompleteColumns":{}}}}},"filters":[],"query":{"language":"kuery","query":""},"visualization":{"axisTitlesVisibilitySettings":{"x":true,"yLeft":true,"yRight":true},"fittingFunction":"None","gridlinesVisibilitySettings":{"x":true,"yLeft":true,"yRight":true},"labelsOrientation":{"x":0,"yLeft":0,"yRight":0},"layers":[{"accessors":["cf81f58a-ebb1-43f9-a202-9cfe5ad07bd6"],"layerId":"dde73e35-b62d-4900-9f81-072dcd82f2e8","layerType":"data","position":"top","seriesType":"bar_stacked","showGridlines":false,"xAccessor":"628dfb9c-50dd-4c07-80e3-a00b2a526b88"}],"legend":{"isVisible":true,"position":"right"},"preferredSeriesType":"bar_stacked","tickLabelsVisibilitySettings":{"x":true,"yLeft":true,"yRight":true},"valueLabels":"hide","yLeftExtent":{"mode":"full"},"yRightExtent":{"mode":"full"}}},"title":"Lens","visualizationType":"lnsXY"},"coreMigrationVersion":"8.0.0","migrationVersion":{"lens":"8.0.0"},"references":[{"id":"d3d7af60-4c81-11e8-b3d7-01146121b73d-test3-newId","name":"indexpattern-datasource-current-indexpattern","type":"index-pattern"},{"id":"d3d7af60-4c81-11e8-b3d7-01146121b73d-test3-newId","name":"indexpattern-datasource-layer-dde73e35-b62d-4900-9f81-072dcd82f2e8","type":"index-pattern"}],"type":"lens","updated_at":"2021-09-21T11:24:12.577Z","namespaces":["test3"]}
    {"index":{"_id":"legacy-url-alias:test2:lens:725a2be0-1ace-11ec-acee-9f628a4e2e5b-test2"}}
    {"legacy-url-alias":{"targetNamespace":"test2","targetType":"lens","targetId":"725a2be0-1ace-11ec-acee-9f628a4e2e5b-test2-newId","sourceId":"725a2be0-1ace-11ec-acee-9f628a4e2e5b-test2"},"type":"legacy-url-alias","references":[]}
    {"index":{"_id":"legacy-url-alias:test3:lens:725a2be0-1ace-11ec-acee-9f628a4e2e5b-test3"}}
    {"legacy-url-alias":{"targetNamespace":"test3","targetType":"lens","targetId":"725a2be0-1ace-11ec-acee-9f628a4e2e5b-test3-newId","sourceId":"725a2be0-1ace-11ec-acee-9f628a4e2e5b-test3"},"type":"legacy-url-alias","references":[]}
    {"index":{"_id":"space:test1"}}
    {"space":{"name":"Test 1: Resolve Exact Match","initials":"T1","description":"In this space, test object(s) will resolve with an \"exactMatch\" outcome.","disabledFeatures":[]},"type":"space"}
    {"index":{"_id":"space:test2"}}
    {"space":{"name":"Test 2: Resolve Alias Match","initials":"T2","description":"In this space, test object(s) will resolve with an \"aliasMatch\" outcome.","disabledFeatures":[]},"type":"space"}
    {"index":{"_id":"space:test3"}}
    {"space":{"name":"Test 3: Resolve Conflict","initials":"T3","description":"In this space, test object(s) will resolve with a \"conflict\" outcome.","disabledFeatures":[]},"type":"space"}
    
  4. Navigate to the Lens with the aliasMatch outcome: http://localhost:5601/s/test2/app/lens#/edit/725a2be0-1ace-11ec-acee-9f628a4e2e5b-test2
  5. Observe that the page fails to load and this error toast is shown:
    image

Expected behavior:

You should be redirected to the page for the new object ID, http://localhost:5601/s/test2/app/lens#/edit/725a2be0-1ace-11ec-acee-9f628a4e2e5b-test2-newId

Any additional context:

I also observed another regression that appears to have been introduced with #108637, where loading a saved object that has a reference to an index pattern that resolves in a "conflict" outcome results in an endless loop of API calls to _bulk_resolve. This can be demonstrated with the staging data above by navigating to http://localhost:5601/test3/app/lens#/edit/725a2be0-1ace-11ec-acee-9f628a4e2e5b-test3. I can verify this regression by reverting 119c742 and that page starts working as expected. Just mentioning this because I plan to fix both problems in the same PR.

Edit: the second problem turned out to be an issue with how the Lens top nav tries to load index patterns, if it doesn't find one (either because the data plugin threw an error for the "conflict" outcome, or the index pattern wasn't found), it will trigger an infinite loop attempting to load the index pattern.

Edit 2: the second problem now has its own issue (#113377) and will be fixed separately.

@jportner jportner added bug Fixes for quality problems that affect the customer experience Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! labels Sep 27, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-security (Team:Security)

@jportner jportner self-assigned this Sep 27, 2021
@exalate-issue-sync exalate-issue-sync bot added impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort labels Sep 28, 2021
@jportner jportner added the Feature:Security/Sharing Saved Objects Platform Security - Sharing Saved Objects feature label Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Security/Sharing Saved Objects Platform Security - Sharing Saved Objects feature impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants