Skip to content

Correct migrated datasources to avoid null state attributes

This code change fixes a bug in GitLab data source functions where empty lists weren't being properly initialized. Previously, when querying for items like cluster agents, group hooks, or project variables and finding no results, the code would leave the list fields uninitialized, which could cause errors or unexpected behavior.

The fix ensures that all list fields (like ClusterAgents, Hooks, Variables, etc.) are properly initialized as empty arrays before populating them with data. This prevents null pointer issues and ensures consistent behavior whether results are found or not.

Additionally, the changes include new test cases that verify the correct behavior when no items are found - confirming that empty lists return a count of "0" rather than causing errors. Some minor cleanup was also done to remove unnecessary temporary variables and improve code organization.

The changes affect multiple GitLab data sources including cluster agents, group hooks, project variables, milestones, and several others, making them all more robust when handling empty result sets.

Resolves #6634

Merge request reports

Loading