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
[Maps] Ensure draw tools updates by index name, not index pattern title #108394
[Maps] Ensure draw tools updates by index name, not index pattern title #108394
Conversation
…dex-pattern-index-mismatch
…dex-pattern-index-mismatch
… index call for separate call
Pinging @elastic/kibana-gis (Team:Geo) |
x-pack/plugins/maps/public/classes/sources/vector_source/vector_source.tsx
Outdated
Show resolved
Hide resolved
const { | ||
payload: { matchingIndexes }, | ||
} = await getMatchingIndexes(this.indexPattern.title); | ||
return matchingIndexes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to handle the case where matchingIndexes is undefined and return empty array in that case. This can be handled here or in getMatchingIndexes. Maybe it would be better if handled in getMatchingIndexes and getMatchingIndexes could just return an string[] and better encapsulate the API response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be consistent with how we're handling other endpoints, I've made it conditional on whether the call was successful or not. Successful calls to the endpoint always return an array. Unsuccessful calls don't which we now handle here by detecting and returning an empty array from the function.
x-pack/plugins/maps/server/data_indexing/get_indexes_matching_pattern.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/maps/server/data_indexing/get_indexes_matching_pattern.ts
Outdated
Show resolved
Hide resolved
@elasticmachine merge upstream |
…dex-pattern-index-mismatch
1a60707
to
7dbc9b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gchaps Would you mind reviewing the copy?
if (errorStatusCode === 404) { | ||
return response.ok({ body: { success: true, matchingIndexes: [] } }); | ||
} else { | ||
logger.error(error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to surface this Error in the Kibana logs? I think since the errors are handled by the UI and messages are displayed to the user, we should not surface these errors in the kibana logs. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's consistent with the handling for our other feature editing endpoints (see here and here for example). I think there's some future work in here around possibly creating a wrapper function for endpoints where we decide if there's some standard or conditional handling we want to apply to all endpoints (error catching, logging, etc.). Since this is a bug fix, I'm mostly just trying to match existing patterns and not rock the boat too much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
code review
x-pack/plugins/maps/public/classes/sources/es_search_source/es_search_source.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/maps/public/classes/sources/es_search_source/es_search_source.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Text LGTM
💚 Build Succeeded
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
…le (elastic#108394) # Conflicts: # x-pack/plugins/maps/public/classes/sources/es_search_source/es_search_source.tsx
Draw tools currently validates index patterns that match a single index. This works fine when both the index and pattern have the same name, but since we were passing the index pattern name rather than the index name for writes, we run into errors when the index pattern has a different name than the index. Like
test*
for the pattern vs.testdraw
for the index. This ensures all 1:1 matches between index patterns and associated indexes are correctly validated and the index name is used for udpates.Also fixed:
/api/maps/getMatchingIndexes?indexPattern=test*
vs./api/maps/getMatchingIndexes/test*