Skip to content
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

go: jsii doesn't handle module imports for private modules #4097

Open
yuriy-yarosh opened this issue May 13, 2023 · 1 comment
Open

go: jsii doesn't handle module imports for private modules #4097

yuriy-yarosh opened this issue May 13, 2023 · 1 comment
Labels
bug This issue is a bug. p2

Comments

@yuriy-yarosh
Copy link

yuriy-yarosh commented May 13, 2023

Describe the bug

In case of a private monorepo, that uses manually rewritten module paths.

module github.com/org/privaterepo/platform/packages/my-cdk8s-turbochart

go 1.20

require (
	github.com/org/privaterepo/platform/utility/crds v0.0.0
)

replace github.com/org/privaterepo/platform/utility/crds => ../../utility/crds

JSII is unable to pick import the shared replaced module.

Expected Behavior

It should be able to pick modules using their respective absolute paths.

Current Behavior

It panics with a failed import

panic: Passed to parameter props of new xrd_apiextensionscrossplaneio.CompositeResourceDefinition: Unable to deserialize value as xrd_apiextensionscrossplaneio.CompositeResourceDefinitionProps | undefined
├── 🛑 Failing value is an object
│      { '$jsii.struct': [Object] }
╰── 🔍 Failure reason(s):
    ╰─ Key 'spec': Unable to deserialize value as xrd_apiextensionscrossplaneio.CompositeResourceDefinitionSpec | undefined
        ├── 🛑 Failing value is an object
        │      { '$jsii.struct': [Object] }
        ╰── 🔍 Failure reason(s):
            ╰─ Key 'versions': Unable to deserialize value as array<xrd_apiextensionscrossplaneio.CompositeResourceDefinitionSpecVersions>
                ├── 🛑 Failing value is an array
                │      [ [Object] ]
                ╰── 🔍 Failure reason(s):
                    ╰─ Index 0: Unable to deserialize value as xrd_apiextensionscrossplaneio.CompositeResourceDefinitionSpecVersions
                        ├── 🛑 Failing value is an object
                        │      { '$jsii.struct': [Object] }
                        ╰── 🔍 Failure reason(s):
                            ╰─ Key 'schema': Unable to deserialize value as xrd_apiextensionscrossplaneio.CompositeResourceDefinitionSpecVersionsSchema | undefined
                                ├── 🛑 Failing value is an object
                                │      { '$jsii.struct': [Object] }
                                ╰── 🔍 Failure reason(s):
                                    ╰─ Key 'openApiv3Schema': Unable to deserialize value as any | undefined
                                        ├── 🛑 Failing value is an object
                                        │      { '$jsii.struct': [Object] }
                                        ╰── 🔍 Failure reason(s):
                                            ╰─ Module 'k8s' not found

Reproduction Steps

Create two golang modules

  1. github.com/org/repo/module1, github.com/org/repo/module2
  2. make a direct replacement in module1 referencing module2 using relative path
module github.com/org/repo/module1

go 1.20

require (
	github.com/org/repo/module2 v0.0.0
)

replace 	github.com/org/repo/module2 => ../module2
  1. JSII will fail to import.

Possible Solution

Implement the respective module rewriting handler for go.mod.

Additional Information/Context

I'm using cdk8s specifically for codegen but not sure if it's a cdk8s issue and the respective handler should be implemented there, as well.

Can provide a sample cdk8s project, for reference and reproducibility.

I've created a separate CDK8S issue with more details regarding my cdk8s use case.

It's an issue where jsii does not generate anything for struct passed into interface{}, also not sure if it's relevant to CDK8S or jsii, but I'd like to get some form of exception, instead of completely blank synthesis.

SDK version used

github.com/aws/jsii-runtime-go v1.81.0 github.com/aws/constructs-go/constructs/v10 v10.2.22

Environment details (OS name and version, etc.)

ArchLinux node.js lts-hydrogen go 1.20

@yuriy-yarosh yuriy-yarosh added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 13, 2023
@yuriy-yarosh yuriy-yarosh changed the title jsii doesn't handle module rewrites for rewritten modules go: jsii doesn't handle local module replacements for private monorepo modules May 13, 2023
@yuriy-yarosh
Copy link
Author

I don't think it's all about monorepo's - I've switched to a single private go module and JSII still unable to find the k8s imported package.

@yuriy-yarosh yuriy-yarosh changed the title go: jsii doesn't handle local module replacements for private monorepo modules go: jsii doesn't handle module imports for private modules May 14, 2023
@mrgrain mrgrain added p2 and removed needs-triage This issue or PR still needs to be triaged. labels Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p2
Projects
None yet
Development

No branches or pull requests

2 participants