Skip to content
This repository was archived by the owner on Dec 11, 2025. It is now read-only.

Typing error with setting RepositoryEnvironment reviews team id #486

Description

@rh-km

Description

Note: I am opening this here based on the feedback from cdktf/cdktf-provider-github#1887, which was my original issue.

I am running into an issue using the Github provider in CDKTF to do the following:

  • Pull an existing team object as a DataGithubTeam.
  • Create a new RepositoryEnvironment resource, and specify the imported team as a review for that environments deployment.

The following terraform code works as expected:

terraform {
  required_providers {
    github = {
      source  = "integrations/github"
      version = "~> 6.0"
    }
  }
}

# Configure the GitHub Provider
provider "github" { owner = "my-org" }

data "github_team" "org_engineers" {
  slug = "org-engineers"
}

resource "github_repository_environment" "test_env" {
  repository = "repo"
  environment = "test-env"
  reviewers {
    teams = [data.github_team.org_engineers.id]
  }
}

Trying to replicate it with CDKTF like so:

from constructs import Construct
from cdktf import App, TerraformStack
from cdktf_cdktf_provider_github.provider import GithubProvider
from cdktf_cdktf_provider_github.repository_environment import (
    RepositoryEnvironment,
    RepositoryEnvironmentReviewers,
)
from cdktf_cdktf_provider_github.data_github_team import DataGithubTeam


class MyStack(TerraformStack):
    def __init__(self, scope: Construct, id: str):
        super().__init__(scope, id)

        # define resources here
        GithubProvider(
            self,
            'Provider',
            owner='org',
        )

        team = DataGithubTeam(self, 'Team', slug='org-engineers')

        RepositoryEnvironment(
            self,
            'Environment',
            repository='repo',
            environment='my-env',
            reviewers=[
                RepositoryEnvironmentReviewers(teams=[team.id])
            ]
        )


app = App()
MyStack(app, "cdktf-test")

app.synth()

For starters, I get a type error from pyright:
Image

When I try and diff it gives me a similar error:

==> cdktf diff

⠧  Synthesizing
[2025-03-12T16:03:27.087] [ERROR] default - Traceback (most recent call last):
  File "/Users/kyle.mcchesney/Dev/var/cdktf-test/./main.py", line 37, in <module>
    MyStack(app, "cdktf-test")
  File "/Users/kyle.mcchesney/Dev/var/cdktf-test/.venv/lib/python3.10/site-packages/jsii/_runtime.py", line 118, in __call__
    inst = super(JSIIMeta, cast(JSIIMeta, cls)).__call__(*args, **kwargs)
  File "/Users/kyle.mcchesney/Dev/var/cdktf-test/./main.py", line 31, in __init__
    RepositoryEnvironmentReviewers(teams=[team.id])
  File "/Users/kyle.mcchesney/Dev/var/cdktf-test/.venv/lib/python3.10/site-packages/cdktf_cdktf_provider_github/repository_environment/__init__.py", line 786, in __init__
    check_type(argname="argument teams", value=teams, expected_type=type_hints["teams"])
  File "/Users/kyle.mcchesney/Dev/var/cdktf-test/.venv/lib/python3.10/site-packages/cdktf_cdktf_provider_github/repository_environment/__init__.py", line 25, in check_type
    return typeguard.check_type(argname=argname, value=value, expected_type=expected_type) # type:ignore
  File "/Users/kyle.mcchesney/Dev/var/cdktf-test/.venv/lib/python3.10/site-packages/typeguard/__init__.py", line 757, in check_type
    checker_func(argname, value, expected_type, memo)
  File "/Users/kyle.mcchesney/Dev/var/cdktf-test/.venv/lib/python3.10/site-packages/typeguard/__init__.py", line 558, in check_union
    raise TypeError('type of {} must be one of ({}); got {} instead'.
ERROR: cdktf encountered an error while synthesizing

Synth command: python3 ./main.py
Error:         non-zero exit code 1

Command output on stderr:

    Traceback (most recent call last):
      File "/Users/kyle.mcchesney/Dev/var/cdktf-test/./main.py", line 37, in <module>
        MyStack(app, "cdktf-test")
      File "/Users/kyle.mcchesney/Dev/var/cdktf-test/.venv/lib/python3.10/site-packages/jsii/_runtime.py", line 118, in __call__
        inst = super(JSIIMeta, cast(JSIIMeta, cls)).__call__(*args, **kwargs)
      File "/Users/kyle.mcchesney/Dev/var/cdktf-test/./main.py", line 31, in __init__
        RepositoryEnvironmentReviewers(teams=[team.id])
      File "/Users/kyle.mcchesney/Dev/var/cdktf-test/.venv/lib/python3.10/site-packages/cdktf_cdktf_provider_github/repository_environment/__init__.py", line 786, in __init__
        check_type(argname="argument teams", value=teams, expected_type=type_hints["teams"])
      File "/Users/kyle.mcchesney/Dev/var/cdktf-test/.venv/lib/python3.10/site-packages/cdktf_cdktf_provider_github/repository_environment/__init__.py", line 25, in check_type
        return typeguard.check_type(argname=argname, value=value, expected_type=expected_type) # type:ignore
      File "/Users/kyle.mcchesney/Dev/var/cdktf-test/.venv/lib/python3.10/site-packages/typeguard/__init__.py", line 757, in check_type
        checker_func(argname, value, expected_type, memo)
      File "/Users/kyle.mcchesney/Dev/var/cdktf-test/.venv/lib/python3.10/site-packages/typeguard/__init__.py", line 558, in check_union
        raise TypeError('type of {} must be one of ({}); got {} instead'.
    TypeError: type of argument teams must be one of (Sequence[Union[int, float]], NoneType); got list instead

Am I doing something wrong or is this an issue with the typing?

Various versions:
OS: MacOS Sequoia Version 15.3.1 (24D70), Apple M3 Pro
Tools:

==> python --version
Python 3.10.14
==> cdktf --version
0.20.7
==> pip freeze
attrs==25.2.0
cattrs==24.1.2
cdktf==0.20.11
cdktf-cdktf-provider-github==14.6.0
constructs==10.4.2
exceptiongroup==1.2.2
importlib_resources==6.5.2
iniconfig==2.0.0
jsii==1.109.0
packaging==24.2
pluggy==1.5.0
publication==0.0.3
pytest==8.3.5
python-dateutil==2.9.0.post0
six==1.17.0
tomli==2.2.1
typeguard==2.13.3
typing_extensions==4.12.2

==> terraform -version
Terraform v1.9.5
on darwin_arm64

Your version of Terraform is out of date! The latest version
is 1.11.1. You can update by downloading from https://www.terraform.io/downloads.html

Versions

cdktf debug
language: python
cdktf-cli: 0.20.7
node: v20.18.1
cdktf: 0.20.11
constructs: 10.4.2
jsii: 1.109.0
terraform: 1.9.5
arch: arm64
os: darwin 24.3.0
python: Python 3.10.14
pip: pip 23.0.1 from /Users/kyle.mcchesney/Dev/var/cdktf-test/.venv/lib/python3.10/site-packages/pip (python 3.10)
pipenv: null
providers
cdktf-cdktf-provider-github (PREBUILT)
terraform provider version: 6.6.0
prebuilt provider version: 14.6.0
cdktf version: ^0.20.0

Providers

┌─────────────────────┬──────────────────┬─────────┬────────────┬─────────────────────────────┬─────────────────┐
│ Provider Name │ Provider Version │ CDKTF │ Constraint │ Package Name │ Package Version │
├─────────────────────┼──────────────────┼─────────┼────────────┼─────────────────────────────┼─────────────────┤
│ integrations/github │ 6.6.0 │ ^0.20.0 │ │ cdktf-cdktf-provider-github │ 14.6.0 │
└─────────────────────┴──────────────────┴─────────┴────────────┴─────────────────────────────┴─────────────────┘

Gist

No response

Possible Solutions

Seems like it's related to the id field, which appears in the TF docs and clearly resolves in TF code, however I do not actually see it in the go file for the data github team. Maybe it is some auto generated field or something?

Workarounds

No response

Anything Else?

No response

References

cdktf/cdktf-provider-github#1887

Help Wanted

  • I'm interested in contributing a fix myself

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions