Skip to content

[Buganizer ID: 461900756] Fix Bug: Gitsync - Instance assignment issue in pull playbook#660

Open
adarshtwy wants to merge 9 commits intomainfrom
git_sync/bug_instance_assignment_missing
Open

[Buganizer ID: 461900756] Fix Bug: Gitsync - Instance assignment issue in pull playbook#660
adarshtwy wants to merge 9 commits intomainfrom
git_sync/bug_instance_assignment_missing

Conversation

@adarshtwy
Copy link
Copy Markdown

@adarshtwy adarshtwy commented Apr 2, 2026

What problem does this PR solve?

When importing a playbook using PullPlaybook, integration instance assignment could fail or produce broken results in several scenarios:

  1. If the specific integration instance used in the exported playbook was missing in the target environment, the system failed to select a fallback instance when the available instances were not "configured" (isConfigured: false). This resulted in steps having no integration instance selected.
  2. If a playbook was previously imported with a bad instance assignment (e.g., from a failed import), subsequent imports would blindly copy the invalid instance ID from the existing step without validating it, perpetuating the broken state.
  3. For single-environment playbooks, if no instances existed in that specific environment but instances were available in the shared environment (*), no fallback was attempted. Similarly, for multi-environment playbooks, if no shared instances existed but instances were available in individual environments, no fallback was attempted.

How does this PR solve the problem?

  1. Include unconfigured instances: We now retrieve all instances of the integration on the target platform, not just the configured ones, and sort them so configured instances appear first. This ensures a fallback is always available.
  2. Validate existing instances before reuse: When updating an existing playbook, we now validate that the instance ID from the existing step actually exists on the target platform before copying it. If validation fails, we fall through to the instance-discovery logic instead of blindly reusing a potentially invalid ID.
  3. Cross-environment fallback: For single-environment playbooks, we now fall back to the shared environment if no instances are found in the specific environment. For multi-environment playbooks, we iterate through individual environments if no shared instances are found.

Approach to solve the problem

  • Modified GitSyncManager._find_integration_instances_for_step to:

    • Include unconfigured instances by removing the isConfigured filter.
    • Prioritize configured instances by sorting the candidate list with configured instances first.
  • Modified GitSyncManager._assign_integration_instance_to_step to:

    • Validate existing step instances via the new _is_valid_existing_instance method before reusing them. For AutomaticEnvironment mode, the fallback instance is validated instead.
    • Add a shared-environment fallback for single-environment playbooks when no instances are found in the specific environment.
    • Add an individual-environment iteration fallback for multi-environment playbooks when no shared instances are found.
  • Added new method GitSyncManager._is_valid_existing_instance that checks whether a given instance ID exists among the available integration instances across all playbook environments and the shared environment.

Any other relevant information

This happens because when creating a playbook and selecting a specific environment, the platform currently lacks the option for the user to provide a fallback to a specific integration instance.

However, when creating a playbook and selecting "All Environments," the platform does provide the fallback instance option. We already implemented this fix in one of our earlier releases.

The validation of existing instances addresses an additional edge case where a prior failed import could leave stale/invalid instance IDs on the existing playbook steps, which would then be blindly propagated on every subsequent import attempt.


Note

Medium Risk
Changes playbook import instance-assignment behavior across environments and may alter which integration instance gets selected, impacting runtime execution if assumptions differ. Logic is contained to Pull Playbook instance discovery/selection and is low security risk but moderate functional risk.

Overview
Fixes Pull Playbook step instance assignment to avoid broken imports when the referenced instance or environment doesn’t exist on the target.

GitSyncManager._assign_integration_instance_to_step now validates existing step instance IDs before reusing them, falls back from a single environment to the shared "*" environment when needed, and for multi-environment playbooks falls back to scanning individual environments when no shared instances exist.

Instance discovery in _find_integration_instances_for_step now returns configured instances when available, otherwise returns unconfigured instances as a last-resort fallback; docs/release metadata were updated and the integration version was bumped to 45.0.

Reviewed by Cursor Bugbot for commit 1acb9a9. Bugbot is set up for automated code reviews on this repo. Configure here.

@adarshtwy adarshtwy requested a review from a team as a code owner April 2, 2026 05:08
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses issues with integration instance assignment during playbook imports. By broadening the search criteria for available instances and introducing strict validation for existing assignments, the changes ensure that playbooks maintain valid integration connections even when specific environment configurations are missing or stale.

Highlights

  • Improved Integration Instance Discovery: Modified the discovery logic to include unconfigured instances as potential fallbacks, ensuring that integration steps are not left unassigned when configured instances are unavailable.
  • Validation of Existing Assignments: Added a validation step to check if existing integration instance IDs are still valid on the target platform before reusing them, preventing the propagation of stale or invalid configurations from previous failed imports.
  • Enhanced Cross-Environment Fallback: Implemented robust fallback mechanisms that search shared environments for single-environment playbooks and iterate through individual environments for multi-environment playbooks when no direct instance match is found.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the GitSync power-up to version 45.0, enhancing the integration instance selection and validation logic. The changes allow the use of unconfigured instances as fallbacks while prioritizing configured ones and introduce validation for existing instance assignments to prevent broken playbooks. Review feedback suggests implementing defensive programming to handle potential null values from API calls and optimizing the instance validation logic to reduce redundant environment checks while ensuring strict type annotations.

Comment thread content/response_integrations/power_ups/git_sync/core/GitSyncManager.py Outdated
@adarshtwy adarshtwy added Bug Something isn't working Git Sync labels Apr 2, 2026
@adarshtwy adarshtwy marked this pull request as draft April 2, 2026 05:37
@adarshtwy adarshtwy marked this pull request as ready for review April 2, 2026 05:37
Comment thread content/response_integrations/power_ups/git_sync/release_notes.yaml Outdated
Comment thread content/response_integrations/power_ups/git_sync/core/GitSyncManager.py Outdated
Comment thread content/response_integrations/power_ups/git_sync/core/GitSyncManager.py Outdated
Comment thread content/response_integrations/power_ups/git_sync/core/GitSyncManager.py Outdated
Comment thread content/response_integrations/power_ups/git_sync/core/GitSyncManager.py Outdated
Comment thread content/response_integrations/power_ups/git_sync/core/GitSyncManager.py Outdated
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1acb9a9. Configure here.

Comment thread content/response_integrations/power_ups/git_sync/release_notes.yaml Outdated
@cursor
Copy link
Copy Markdown

cursor bot commented Apr 10, 2026

You have used all of your free Bugbot PR reviews.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 10, 2026

You have used all of your free Bugbot PR reviews.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@adarshtwy adarshtwy marked this pull request as draft April 10, 2026 10:01
@adarshtwy adarshtwy marked this pull request as ready for review April 10, 2026 10:01
@adarshtwy adarshtwy marked this pull request as draft April 13, 2026 09:17
@adarshtwy adarshtwy marked this pull request as ready for review April 13, 2026 09:17
@cursor
Copy link
Copy Markdown

cursor bot commented Apr 15, 2026

You have used all of your free Bugbot PR reviews.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@github-actions
Copy link
Copy Markdown

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

git_sync

Validation Name Details
⚠️ Test Config Validation 'git_sync' is missing tests/config.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working Git Sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants