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

Panic in askStaticSite function #5524

Closed
antonioau opened this issue Dec 4, 2023 · 5 comments
Closed

Panic in askStaticSite function #5524

antonioau opened this issue Dec 4, 2023 · 5 comments
Labels
type/bug Issues that are bugs.

Comments

@antonioau
Copy link

Title: Panic in askStaticSite function
Description: I am experiencing a panic in the askStaticSite function of the Copilot CLI tool. The panic is occurring on line 540 of the svc_init.go file. I have tried debugging the function, but I am unable to identify the root cause of the problem.

Steps to reproduce:

Run the copilot init svc command.
Select the "Static site" option.
The panic will occur when the tool prompts you for the static site URL.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x18 pc=0x105360c14]

goroutine 1 [running]:
github.com/aws/copilot-cli/internal/pkg/cli.(*initSvcOpts).askStaticSite(0x14000174200)
        /codebuild/output/src1991231604/src/internal/pkg/cli/svc_init.go:540 +0x284
github.com/aws/copilot-cli/internal/pkg/cli.(*initSvcOpts).askSvcDetails(0x14000174200?)
        /codebuild/output/src1991231604/src/internal/pkg/cli/svc_init.go:457 +0x64
github.com/aws/copilot-cli/internal/pkg/cli.(*initSvcOpts).Ask(0x14000174200)
        /codebuild/output/src1991231604/src/internal/pkg/cli/svc_init.go:369 +0x114
github.com/aws/copilot-cli/internal/pkg/cli.(*initOpts).loadWkld(0x14000164300)
        /codebuild/output/src1991231604/src/internal/pkg/cli/init.go:441 +0xc0
github.com/aws/copilot-cli/internal/pkg/cli.(*initOpts).Run(0x14000164300)
        /codebuild/output/src1991231604/src/internal/pkg/cli/init.go:384 +0x12c
github.com/aws/copilot-cli/internal/pkg/cli.BuildInitCmd.func1(0x0?, {0x0?, 0x0?, 0x0?})
        /codebuild/output/src1991231604/src/internal/pkg/cli/init.go:634 +0x110
github.com/aws/copilot-cli/internal/pkg/cli.BuildInitCmd.runCmdE.func2(0x14000172300?, {0x1400044aeb0?, 0x4?, 0x10539057b?})
        /codebuild/output/src1991231604/src/internal/pkg/cli/cli.go:72 +0x88
github.com/spf13/cobra.(*Command).execute(0x14000352600, {0x1400044ae70, 0x1, 0x1})
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:983 +0x82c
github.com/spf13/cobra.(*Command).ExecuteC(0x14000352300)
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x344
github.com/spf13/cobra.(*Command).Execute(...)
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:1039
main.main()
        /codebuild/output/src1991231604/src/cmd/copilot/main.go:34 +0x24
@Lou1415926 Lou1415926 added the type/bug Issues that are bugs. label Dec 5, 2023
@Lou1415926
Copy link
Contributor

Hey @antonioau !! Thank you very much for bringing this to our attention, and sincere apology for the issue 🙇🏼‍♀️ ! I've sent out a fix #5530 which will be shipped in the next release!

This panic should happen when you satisfy all of the following:

  1. You run copilot init to init a static site
  2. You are already in a workspace (meaning that you have copilot/.workspace within 5 levels up in the directory tree")

For now, until we ship the fix, can you run copilot svc init to initialize a static site?

Thank you again for opening the issue!!

@surrealchemist
Copy link

surrealchemist commented Dec 11, 2023

I just ran into this same issue. I ran svc init instead. I had a file without read access that made it fail. I removed that and then it prompts for way too many files. It looks like the directories are relative either. If I check this repo out somewhere else the directory might have a different name so it doesn't seem like a good pattern. This is the first time I am using static site feature so I am not sure if this is how it normally behaves but it seems odd. I suppose you can always modify the manifest afterwards?

EDIT: after I selected a path it started trying to update another unrelated infrastructure stack so i did a ctrl-c to stop it. I'm not sure what it would have done to my other app.

@iamhopaul123
Copy link
Contributor

Hello @surrealchemist. Sorry for running into this issue. We'll make a patch release fixing this soon.

I suppose you can always modify the manifest afterwards?

Yes. This is correct. You can always modify the manifest afterward. You can use copilot svc deploy --diff so that it prints the CloudFormation template changes and prompt you for confirmation before deploying any changes.

it started trying to update another unrelated infrastructure stack

It's expected if it is updating your application infrastructure stack, which is the bootstrap stack Copilot creates for each environment region.

@iamhopaul123
Copy link
Contributor

Hello! The fix is now released in v1.32.1: https://github.com/aws/copilot-cli/releases/tag/v1.32.1

@surrealchemist
Copy link

Thanks. I get prompted if I want to use an existing app now, which makes sense. I can say no and then it creates its own infrastructure stack. Looking a lot better now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Issues that are bugs.
Projects
None yet
Development

No branches or pull requests

4 participants