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

Failure to save aws config after registry sync run #785

Open
meyerjrr opened this issue Oct 22, 2024 · 1 comment
Open

Failure to save aws config after registry sync run #785

meyerjrr opened this issue Oct 22, 2024 · 1 comment

Comments

@meyerjrr
Copy link
Contributor

A user has reported not being able to run and complete a registry sync run. This actually caused them not to be able to request access due to the auto sync functionality.

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
gopkg.in/ini%2ev1.(*File).writeToBuffer(0x140005c0700, {0x0, 0x0})
        /Users/runner/go/pkg/mod/gopkg.in/[email protected]/file.go:352 +0xe40
gopkg.in/ini%2ev1.(*File).SaveToIndent(0x140005c0500?, {0x14000133278, 0x17}, {0x0?, 0x0?})
        /Users/runner/go/pkg/mod/gopkg.in/[email protected]/file.go:530 +0x30
gopkg.in/ini%2ev1.(*File).SaveTo(...)
        /Users/runner/go/pkg/mod/gopkg.in/[email protected]/file.go:540
github.com/common-fate/granted/pkg/granted/registry.SyncProfileRegistries({0x104259dc0, 0x140007184b0}, 0x0)
        /Users/runner/work/granted-cli-build/granted-cli-build/granted/pkg/granted/registry/sync.go:112 +0x574
github.com/common-fate/granted/pkg/autosync.runSync({0x104259dc0, 0x140007184b0}, {{0x1400004a800?, 0x103112f00?}, 0x10408dd40?}, 0x0)
        /Users/runner/work/granted-cli-build/granted-cli-build/granted/pkg/autosync/registry.go:22 +0x6c
github.com/common-fate/granted/pkg/autosync.Run({0x104259dc0, 0x140007184b0}, 0x0)
        /Users/runner/work/granted-cli-build/granted-cli-build/granted/pkg/autosync/autosync.go:44 +0x120
github.com/common-fate/granted/pkg/granted.GetCliApp.WithAutosync.func4(0x1?)
        /Users/runner/work/granted-cli-build/granted-cli-build/granted/pkg/granted/middleware/sync.go:10 +0x2c
github.com/common-fate/granted/pkg/granted.GetCliApp.WithBeforeFuncs.func5(0x1400063c240)
        /Users/runner/work/granted-cli-build/granted-cli-build/granted/pkg/granted/middleware/cli.go:26 +0x84
github.com/urfave/cli/v2.(*Command).Run(0x104ccd5a0, 0x1400063c240, {0x140001c2ba0, 0x3, 0x3})
        /Users/runner/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:214 +0x3c4
github.com/urfave/cli/v2.(*Command).Run(0x140005f02c0, 0x1400082a200, {0x1400015a000, 0x4, 0x4})
        /Users/runner/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:267 +0x8f8
github.com/urfave/cli/v2.(*App).RunContext(0x14000714000, {0x104259b20, 0x104e0ab00}, {0x1400015a000, 0x4, 0x4})
        /Users/runner/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:332 +0x4f8
github.com/urfave/cli/v2.(*App).Run(...)
        /Users/runner/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:309
main.main()
        /Users/runner/work/granted-cli-build/granted-cli-build/granted/cmd/granted/main.go:51 +0x2dc

Looks to be failing to failing to write multi line comments to the config file using the ini library Granted uses.

for i, sname := range f.sectionList {
sec := f.SectionWithIndex(sname, f.sectionIndexes[i])
if len(sec.Comment) > 0 {
	// Support multiline comments
	lines := strings.Split(sec.Comment, LineBreak)
	for i := range lines {
		if lines[i][0] != '#' && lines[i][0] != ';' { <---- Panic occurring here
			lines[i] = "; " + lines[i]
		} else {
			lines[i] = lines[i][:1] + " " + strings.TrimSpace(lines[i][1:])
		}

		if _, err := buf.WriteString(lines[i] + LineBreak); err != nil {
			return nil, err
		}
	}
}
@EloyTolosaDev
Copy link

Hi!
I was looking for an open issue to contribute to the project and I saw this.
Could you provide more information about how was the config file that you want to read while the registry sync?
I suspect this could be a problem of the golang ini package configuration but I have to look more closely.

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants