elastic / connectors

Source code for all Elastic connectors, developed by the Search team at Elastic, and home of our Python connector development framework
https://www.elastic.co/guide/en/enterprise-search/master/index.html
Other
58 stars 116 forks source link

Confluence connector fails to sync when list of spaces contains a trailing comma #2643

Open sandermvanvliet-stack opened 1 week ago

sandermvanvliet-stack commented 1 week ago

Bug Description

When the Confluence connector is configured with a comma separated list of space keys and there is a trailing comma the sync job fails with the error Spaces '' are not available. Available spaces are: SP1, SP2, SP3....

The issue can be traced to the _remote_validation function where the list of spaces retrieved from Confluence is compared with the spaces configured for the connector (provided via self.spaces).

When the user configures the space keys with a trailing comma, the self.spaces array contains an item that is an empty string. That in turn results in the set(self.spaces) - set(space_keys) operation to return that empty string item and thus the error message triggers.

Technically the error is correct, the Confluence space "empty string" does not exist but the message looks odd to say the least 🙂

To Reproduce

Steps to reproduce the behavior:

  1. Configure a Confluence connector in Elastic Enterprise Search and specify the spaces as SP1, SP2, (note the trailing comma)
  2. Save the connector
  3. Wait for the initial sync to complete (trigger manually if necessary)
  4. Observe the failure
  5. In the logs observe the error Spaces '' are not available. Available spaces are: SP1, SP2, SP3....

Expected behavior

The error is not triggered and the sync succeeds

Environment

Elastic 8.13.1

seanstory commented 1 week ago

Thanks for filing! Seems reasonable and straightforward. Feel free to file a PR, or we'll eventually get there. :)