Skip to content

Don't assume array indexes exist, check first - #352

Merged
Andriy Knysh (aknysh) merged 3 commits into
cloudposse:masterfrom
johannawalter:master
Mar 24, 2023
Merged

Andriy Knysh (aknysh) merged 3 commits into
cloudposse:masterfrom
johannawalter:master

Conversation

@johannawalter

Copy link
Copy Markdown
Contributor

This is the first instance I've seen us run into the issue of atmos simply panicking. Tracking it back I found unchecked array indexes (index assumed to exist). These checks will prevent those panics in the future and, were applicable, return a useful error message.

Pre-patch:

√ : [<REDACTED>] (HOST) infrastructure ⨠ atmos terraform state list -s <REDACTED>
panic: runtime error: index out of range [2] with length 2

goroutine 1 [running]:
github.com/cloudposse/atmos/internal/exec.processArgsAndFlags({_, _}, {_, _, _})
	/home/runner/work/atmos/atmos/internal/exec/utils.go:1259 +0x203c
github.com/cloudposse/atmos/internal/exec.processCommandLineArgs({_, _}, _, {_, _, _})
	/home/runner/work/atmos/atmos/internal/exec/utils.go:143 +0xbc
github.com/cloudposse/atmos/internal/exec.ExecuteTerraformCmd(0x40006bfd48?, {0x40000e2c40?, 0x4?, 0x1243ef0?})
	/home/runner/work/atmos/atmos/internal/exec/terraform.go:23 +0x70
github.com/cloudposse/atmos/cmd.glob..func10(0x40006bfe18?, {0x40000e2c40?, 0xfffff725f69a?, 0x40000a6b90?})
	/home/runner/work/atmos/atmos/cmd/terraform.go:16 +0x20
github.com/spf13/cobra.(*Command).execute(0x1f2fca0, {0x40000e2c40, 0x4, 0x4})
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:920 +0x5c8
github.com/spf13/cobra.(*Command).ExecuteC(0x1f2f9c0)
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1044 +0x368
github.com/spf13/cobra.(*Command).Execute(...)
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:968
github.com/cloudposse/atmos/cmd.Execute(...)
	/home/runner/work/atmos/atmos/cmd/root.go:20
main.main()
	/home/runner/work/atmos/atmos/main.go:9 +0x2c

Post-patch:

√ : [<REDACTED>] (HOST) infrastructure ⨠ atmos terraform state list -s <REDACTED>
command requires an argument: state list

Comment thread internal/exec/utils.go Resolved

@aknysh Andriy Knysh (aknysh) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks Johanna Walter (@johannawalter) , please see comments

@aknysh Andriy Knysh (aknysh) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aknysh
Andriy Knysh (aknysh) merged commit af84fc3 into cloudposse:master Mar 24, 2023
Erik Osterman (Cloud Posse) (osterman) added a commit that referenced this pull request Nov 14, 2026
…s and joi

Go: andybalholm/brotli v1.2.1 -> v1.2.7 (GO-2026-6888), klauspost/compress
v1.19.2 -> v1.20.2 (GO-2026-6865), go.opentelemetry.io/otel family
v1.46.0 -> v1.47.0 (Dependabot #356, #357).
website: follow-redirects ^1.16.2 (#350), joi ^17.13.9 (#352) via
pnpm.overrides. NOTICE regenerated.

Not fixed: go-jose/v3 (no patch), tinypool and minimatch (major bump
blocked by dependabot ignore policy), deepmerge (no patch).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
zack-is-cool pushed a commit to zack-is-cool/atmos that referenced this pull request Nov 17, 2026
…dposse#3689)

* refactor: resolve lint debt in config, exec and plugin packages

Split out of the Git push retry PR so that review stays focused. Refactors
pkg/config YAML decoding and environment helpers, passes large option structs
by pointer, groups stack search results, and replaces dynamic errors with
wrapped sentinels across internal/exec, pkg/plugin, pkg/helmfile and
pkg/script. Also aligns the custom lint version and the no-network allowlist.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* fix(schema): describe provider credentials in the generated schema

Replace lint-code comments with user-facing field descriptions and regenerate
the atmos.yaml JSON schema, which publishes field comments as descriptions.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* fix(config): wrap env parse errors and share stack-config sentinels

Wrap bare strconv parse errors in pkg/config/environment.go with
ErrInvalidConfig and the offending variable name, preserving the
underlying parser error. Move the four stack-config sentinels from
pkg/config/utils.go into errors/errors.go as exported Err* values with
unchanged messages.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* fix(security): bump brotli, klauspost/compress, otel, follow-redirects and joi

Go: andybalholm/brotli v1.2.1 -> v1.2.7 (GO-2026-6888), klauspost/compress
v1.19.2 -> v1.20.2 (GO-2026-6865), go.opentelemetry.io/otel family
v1.46.0 -> v1.47.0 (Dependabot cloudposse#356, cloudposse#357).
website: follow-redirects ^1.16.2 (cloudposse#350), joi ^17.13.9 (cloudposse#352) via
pnpm.overrides. NOTICE regenerated.

Not fixed: go-jose/v3 (no patch), tinypool and minimatch (major bump
blocked by dependabot ignore policy), deepmerge (no patch).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

---------

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
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

Successfully merging this pull request may close these issues.

2 participants