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

[Connector API] Don't index literal nulls to connector doc #110543

Merged

Conversation

jedrazb
Copy link
Member

@jedrazb jedrazb commented Jul 5, 2024

Changes

As part of elastic/elasticsearch-specification#2675, we realized that when creating a connector, all properties are written to the index, even if they have a null value. This creates inconsistency between what can be optional and what is actually nullable (semantic-null). We don't need to store literal nulls in the connector index; it's fine to treat connector properties as optionals.

Previously, null values were written to the index to match the status quo (where every single property was preset to null), but this is unnecessary.

This PR ensures that properties are only written to the index upon connector creation if the field is non-null. As a result, fields like last_seen or sync_cursor won't be written to the index and won't be present in the response if they are null. This changes the current behavior where these fields are set to null.

I've tested this change with Kibana, Connector APIs, and the connector service, and everything is working fine. Additionally, this fix will resolve failing client tests due to properties that contain null values.

Code references

The logic to create connector is in the ConnectorIndexService, see createConnector method. This initialises Connector object with user-provided args and presets other properties to default values. There are a number of undefined properties (like last_seen, sync_cursor, etc).

This logic uses Connector's toXContent method to write "JSON" to index. The changes to toXContent from this PR ensure that we don't write nulls to index.

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/ingestion-team (Team:Search - Extract & Transform)

@elasticsearchmachine elasticsearchmachine added the Team:SearchOrg Meta label for the Search Org (Enterprise Search) label Jul 5, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/ent-search-eng (Team:SearchOrg)

@jedrazb
Copy link
Member Author

jedrazb commented Jul 10, 2024

@elasticsearchmachine merge upstream

@jedrazb
Copy link
Member Author

jedrazb commented Jul 10, 2024

@elasticmachine merge upstream

@jedrazb jedrazb merged commit f794966 into elastic:main Jul 10, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>non-issue :SearchOrg/Extract&Transform Label for the Search E&T team Team:Search - Extract & Transform Team:SearchOrg Meta label for the Search Org (Enterprise Search) v8.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants