-
Notifications
You must be signed in to change notification settings - Fork 10
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
Adding teams breaks RepositoryEnvironment reviewers and causes a panic #278
Comments
Hi @JDTX0 I'm trying to reproduce your issue... what is |
@mikhailshilkov Thanks for your fast reply. It's a map containing values to pass to Here's an example of the map we're passing: environments: new Map([
[
'test',
{
deploymentBranchPolicy: {
customBranchPolicies: ['test', 'release/*'],
protectedBranches: false,
},
reviewers: {
teams: ['team-name-1', 'team-name-2', 'team-name-3'],
},
waitTimer: 1,
},
], Note: values have been replaced with sample values, but they contain real team names in our env Most importantly, we're passing the team names in the reviewers object. The team names are then converted to ID's in the Just for some context, we use maps for pretty much everything, and we use Unfortunately I don't have a standalone program for reproducing this. I can probably try to create one if you're unable to reproduce the problem, but all of the code to reproduce should be available in this report. |
What does this step mean exactly?
Are you adding a team to reviewers? Are you creating a new
That would be quite helpful. |
@mikhailshilkov I spent some time whittling down our production code to the smallest usable example that reproduces the problem. I've included the minimal program below. Here's how to reproduce: Note: I created a brand new org in GitHub for testing and used a GitHub Enterprise trial for it.
Here's the files for the project.
import * as pulumi from "@pulumi/pulumi";
import * as github from "@pulumi/github";
const orgName = "your-org-name";
const repoName = "testrepo";
const testTeam = {
name: "testteam1",
};
const testTeam2 = {
name: "testteam2",
};
const teams = [...[testTeam]];
// const teams = [...[testTeam, testTeam2]];
const providers = new Map<string, github.Provider>();
if (!providers.has(orgName)) {
providers.set(
orgName,
new github.Provider(orgName, {
owner: orgName,
})
);
}
const p = providers.get(orgName);
const teamsMap = teams.map((teamSettings) => {
const team = new github.Team(
`${orgName}-${teamSettings.name}`,
{
...teamSettings,
...{ privacy: "closed" },
},
{ provider: p }
);
return team;
});
const r = new github.Repository(
`${orgName}-${repoName}}`,
{
name: `${repoName}`,
visibility: "private",
},
{ provider: p }
);
new github.RepositoryEnvironment(
`${orgName}-${repoName}`,
{
environment: "dev",
repository: `${repoName}`,
reviewers: [
{
teams: getTeamIds(["testteam1"], teamsMap),
},
],
},
{ provider: p, dependsOn: [r] }
);
function getTeamIds(
slugs: string[],
teams: github.Team[]
): pulumi.Output<number[]> {
return pulumi
.all(
teams.map((t) =>
pulumi
.all([t.slug, t.id])
.apply(([slug, id]) => (slugs.includes(slug) ? parseInt(id) : null))
)
)
.apply((ids) => ids.filter((v) => v !== null) as number[]);
}
{
"name": "gh-provider-issue-repro",
"main": "index.ts",
"devDependencies": {
"@types/node": "^14"
},
"dependencies": {
"@pulumi/github": "^5.1.0",
"@pulumi/pulumi": "^3.0.0"
}
}
name: gh-provider-issue-repro
runtime: nodejs
description: A Pulumi program to reproduce a panic with adding new teams Hope that helps. If you have any questions or need anything else, please let me know. |
@mikhailshilkov Any chance someone can take a look at this issue? We're still running into the problem and we have to make teams manually + import them into the Pulumi state to work around this problem. |
What happened?
Adding additional teams using
github.Team
causes existingRepositoryEnvironments
resources fail to fetch team id values for the reviewers and then causes an interface conversion panic onpreview
&up
.Even if the new team isn't related in any way to the existing RepositoryEnvironment, it still panics. In other words, the new team being added is not added to the reviewers, so it should be unaffected, but it still is.
Here's the panic:
I ran
pulumi preview --logtostderr --logflow -v=9 2>&1 | tee -a debug.log
and got some debug info:Most interesting to me is that the
reviewers
is getting set to a map of teams containing74D93920-ED26-11E3-AC10-0800200C9A66
which is a special value in Terraform that represents an unknown variableI imagine that value (
74D93920-ED26-11E3-AC10-0800200C9A66
) is what's causing the panic as it's a string, and the interface expects an integer.Oddly this doesn't happen for every RepositoryEnvironment. There's a few RepositoryEnvironments above that one in the log that get the correct team ids and don't have that
74D93920-ED26-11E3-AC10-0800200C9A66
string anywhere.I've currently been working around this bug by manually creating the team on the GitHub side, then importing the team into Pulumi's state using
pulumi import
, then the preview/up works fine with the new team defined.As an aside, it'd be great if we could pass the custom team names directly instead of having to provide the ID's and resolve those id's ourselves. I see something similar was added recently for branch protection rules in integrations/terraform-provider-github#1020 -- If that's out of the scope of this (which I assume it is, since this is just a bridge of sorts), then I'm happy to open a feature request upstream.
Steps to reproduce
github.Team
, fully apply the changes and ensure the teams are created in GHRepositoryEnvironments
with some team ids as thereviewers
, fully apply the changes, ensure the repo environments are createdpulumi preview
Here's the code for function we're using to map team names to team ids:
And here's the code that's calling that function:
Expected Behavior
The preview/up works as expected, and the addition of a new team does not cause a panic
Actual Behavior
The preview panics with the interface conversion error.
Output of
pulumi about
Note: I've stripped the resources and some info here, but the relevant software versions are included. If you really need the full output, please reach out to me privately.
Also note: I've tried upgrading everything to the latest versions available, it made no difference, still panics.
Additional context
No response
Contributing
Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).
The text was updated successfully, but these errors were encountered: