Skip to content

[BUG] Enable importing github_emu_group_mapping for Group with multiple teams#3054

Merged
nickfloyd merged 15 commits intointegrations:mainfrom
F-Secure-web:fix-emu-group-mapping-import-multiple-teams-3030
Jan 16, 2026
Merged

[BUG] Enable importing github_emu_group_mapping for Group with multiple teams#3054
nickfloyd merged 15 commits intointegrations:mainfrom
F-Secure-web:fix-emu-group-mapping-import-multiple-teams-3030

Conversation

@deiga
Copy link
Copy Markdown
Collaborator

@deiga deiga commented Jan 7, 2026

Superseded #3043

Resolves #3030


Before the change?

  • No tests for github_emu_group_mapping
  • Import set wrong ID
  • Not able to import Groups with multiple teams mapped
  • Using legacy CRUD provider functions

After the change?

  • Adds tests for github_emu_group_mapping
  • Fixes import logic
  • Enabled importing Group with multiple team mappings
  • Refactor to use Context-aware functions

Pull request checklist

  • Schema migrations have been created if needed (example)
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 7, 2026

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@github-actions github-actions bot added the Type: Bug Something isn't working as documented label Jan 7, 2026
@deiga deiga changed the title Fix emu group mapping import multiple teams 3030 [BUG] Enable importing github_emu_group_mapping for Group with multiple teams Jan 7, 2026
@deiga deiga force-pushed the fix-emu-group-mapping-import-multiple-teams-3030 branch from beb7f4d to abb3de3 Compare January 7, 2026 21:24
Copy link
Copy Markdown
Collaborator

@stevehipwell stevehipwell left a comment

Choose a reason for hiding this comment

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

As we as the inline comments, we need to be careful when using tflog that it can only be used with contexts injected by TF (e.g. CreateContext).

@stevehipwell stevehipwell added this to the v6.10.0 Release milestone Jan 8, 2026
@deiga deiga force-pushed the fix-emu-group-mapping-import-multiple-teams-3030 branch from abb3de3 to a523161 Compare January 8, 2026 21:44
@deiga deiga requested a review from stevehipwell January 8, 2026 21:44
@deiga deiga force-pushed the fix-emu-group-mapping-import-multiple-teams-3030 branch from a523161 to e8cceb1 Compare January 9, 2026 22:50
@deiga deiga requested a review from stevehipwell January 10, 2026 21:32
@deiga deiga requested a review from stevehipwell January 13, 2026 20:10
@deiga deiga force-pushed the fix-emu-group-mapping-import-multiple-teams-3030 branch from b572afb to 5302481 Compare January 14, 2026 20:25
@deiga deiga requested a review from stevehipwell January 14, 2026 21:16
Copy link
Copy Markdown
Collaborator

@stevehipwell stevehipwell left a comment

Choose a reason for hiding this comment

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

I've just realized what you're doing here, which is what I've been working on with the other team resources. I think you need to make the following changes (none of which I'd consider breaking).

  • Resource ID format to <team-id>:<team-slug>:<group-id>
    • State migration to update the ID
  • Import to accept <team-slug>:<group-id>
    • Lookup team ID and update resource ID to correct format
  • Make group ID force new
    • Otherwise changing the group would leave orphaned links
  • Add custom diff function
    • Force new if team slug points at new ID
  • Separate create and update functions

The top 3 steps would be good enough to fix the bug and stop records being orphaned (unless the team slug was changed to point at a completely different team).

@deiga
Copy link
Copy Markdown
Collaborator Author

deiga commented Jan 15, 2026

I've just realized what you're doing here, which is what I've been working on with the other team resources. I think you need to make the following changes (none of which I'd consider breaking).

  • Resource ID format to <team-id>:<team-slug>:<group-id>

    • State migration to update the ID
  • Import to accept <team-slug>:<group-id>

    • Lookup team ID and update resource ID to correct format
  • Make group ID force new

    • Otherwise changing the group would leave orphaned links
  • Add custom diff function

    • Force new if team slug points at new ID
  • Separate create and update functions

The top 3 steps would be good enough to fix the bug and stop records being orphaned (unless the team slug was changed to point at a completely different team).

@stevehipwell These definitely sound like worthwhile changes, but I wonder if we need to do them before merging this?
I'd rather get this PR merged now, to enable these imports and then create a follow-up PR to address those changes.

@stevehipwell
Copy link
Copy Markdown
Collaborator

@deiga you need the first 2 steps above to fix the bug as otherwise you'll have duplicate IDs when teams have multiple groups attached. The 3rd step costs nothing and fixes another set of current defects. I think maybe we move this PR and the issue to the v6.11.0 milestone to give us a bit more time?

@deiga
Copy link
Copy Markdown
Collaborator Author

deiga commented Jan 15, 2026

@deiga you need the first 2 steps above to fix the bug as otherwise you'll have duplicate IDs when teams have multiple groups attached. The 3rd step costs nothing and fixes another set of current defects. I think maybe we move this PR and the issue to the v6.11.0 milestone to give us a bit more time?

@stevehipwell The ID uses team slug as the ID, so duplicate IDs shouldn't be an issue as each team can have exactly 1 mapping.

Like I said, I'll happily address those in a follow-up as I don't see any of them necessary for getting this merged

@deiga deiga requested a review from stevehipwell January 15, 2026 18:09
Copy link
Copy Markdown
Collaborator

@stevehipwell stevehipwell left a comment

Choose a reason for hiding this comment

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

Ok, at a bare minimum can we please only support two part import IDs. That way import doesn't have to lookup the team and we don't get any drift. It can save the original ID pattern for now and we can fix up the rest of my points later

deiga added 8 commits January 16, 2026 15:26
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Which was found by our new tests!

Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
deiga added 6 commits January 16, 2026 15:26
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
@deiga deiga force-pushed the fix-emu-group-mapping-import-multiple-teams-3030 branch from 3e24afb to c853582 Compare January 16, 2026 13:30
Copy link
Copy Markdown
Collaborator

@stevehipwell stevehipwell left a comment

Choose a reason for hiding this comment

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

Sorry @deiga I don't see how this resource works at all? The read just checks that the group has a team linked, not that the relationship is the one being managed by TF. It looks like the SDK is missing the required endpoint.

Let's push this PR into the next release. I'll open a PR to get the endpoint supported in the SDK.

Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Copy link
Copy Markdown
Collaborator

@stevehipwell stevehipwell left a comment

Choose a reason for hiding this comment

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

Thanks @deiga. This PR fixes the import bug and the other defects are pre existing so I think we should get it merged and fix the bugs in a separate PR.

@nickfloyd nickfloyd merged commit bfb6a49 into integrations:main Jan 16, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug Something isn't working as documented

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Importing GitHub EMU group mapping fails for more than 1 team

3 participants