Skip to content

Fix ATMOS_IDENTITY=false not working (issue #1898) - #1900

Merged
Andriy Knysh (aknysh) merged 2 commits into
mainfrom
osterman/fix-issue-1898
Dec 21, 2025
Merged

Andriy Knysh (aknysh) merged 2 commits into
mainfrom
osterman/fix-issue-1898

Conversation

@osterman

@osterman Erik Osterman (Cloud Posse) (osterman) commented Dec 20, 2025 •

Copy link
Copy Markdown
Member

what

  • Fixed ATMOS_IDENTITY=false and --identity=false not being recognized as a way to disable authentication
  • Added normalizeIdentityValue() helper to convert "false", "0", "no", "off" to internal disabled sentinel
  • Added IsDisabled() method to IdentitySelector for checking if authentication is disabled
  • Added comprehensive tests for identity flag normalization

why

When ATMOS_IDENTITY=false is set via environment variable or --identity=false is passed as a flag, the value "false" was being treated as a literal identity name instead of being normalized to the internal __DISABLED__ sentinel value. This caused auth validation to fail with "Identity specified was not found in the auth config." Users now have a clear way to disable authentication.

references

Closes #1898

Summary by CodeRabbit

  • New Features

    • Enhanced identity flag handling to recognize various representations of disabled state (false, 0, no, off in any case variation).
    • Added capability to check if authentication has been explicitly disabled.
  • Tests

    • Added comprehensive test coverage for identity flag normalization and disabled state detection across multiple scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

When ATMOS_IDENTITY=false or --identity=false is set, the value "false" is now
properly normalized to the internal disabled sentinel value (__DISABLED__) instead
of being treated as a literal identity name. This allows users to disable authentication
via environment variable or flag.

Changes:
- Add normalizeIdentityValue() helper in pkg/flags/global_registry.go
- Update parseIdentityFlag() to normalize "false", "0", "no", "off" values
- Add IsDisabled() method to IdentitySelector for checking disabled state
- Add comprehensive tests for identity flag normalization

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 4.5 <[email protected]>
@github-actions github-actions Bot added the size/m Medium size PR label Dec 20, 2025
@github-actions

github-actions Bot commented Dec 20, 2025 •

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

@osterman Erik Osterman (Cloud Posse) (osterman) added the patch A minor, backward compatible change label Dec 20, 2025
@coderabbitai

coderabbitai Bot commented Dec 20, 2025

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This change adds support for disabling Atmos identity/authentication via command-line flags and environment variables. A new IsDisabled() method is introduced to check if identity is explicitly disabled, while a normalization helper converts various "false" representations ("false", "0", "no", "off") to a disabled sentinel value. Tests cover the new functionality and normalization behavior.

Changes

Cohort / File(s) Change Summary
Identity Selector Enhancement
pkg/flags/global/identity_selector.go
Adds public method IsDisabled() bool that returns true when identity flag is provided with disabled sentinel value. Includes performance tracking.
Identity Selector Tests
pkg/flags/global/flags_test.go
Introduces TestIdentitySelector_IsDisabled test suite validating disabled scenarios. ⚠️ Note: Test appears twice in file (duplicate definition).
Identity Flag Normalization
pkg/flags/global_registry.go
Adds normalizeIdentityValue() helper to convert common boolean false representations to disabled sentinel. Updates parseIdentityFlag to normalize values when explicitly provided via flag or config. Imports "strings" package.
Normalization Tests
pkg/flags/global_registry_test.go
New test file with three test cases: normalization of disabled values, unprovided flag behavior, and flag change scenarios. Uses minimal cobra.Command setup with viper for input simulation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Duplicate test definition: The TestIdentitySelector_IsDisabled appears twice in flags_test.go and needs clarification or removal.
  • Normalization logic: Verify normalizeIdentityValue handles all edge cases and casing variants correctly.
  • Integration point: Review how parseIdentityFlag applies normalization and maintains correct provided/not-provided flag state.
  • Test coverage: Confirm test scenarios adequately cover the disable-identity behavior end-to-end.

Suggested labels

minor

Suggested reviewers

  • aknysh

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: fixing the ATMOS_IDENTITY=false issue #1898, which is the primary objective of this PR.
Linked Issues check ✅ Passed The PR implementation fully addresses the linked issue #1898: adds normalization for disabled representations (false/0/no/off) [#1898], adds IsDisabled() method [#1898], updates parseIdentityFlag to normalize values [#1898], and includes comprehensive tests [#1898].
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing ATMOS_IDENTITY=false handling: identity selector logic, flag parsing, normalization helpers, and related tests. No extraneous modifications detected.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch osterman/fix-issue-1898

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f032f56 and 8fac2e7.

📒 Files selected for processing (4)
  • pkg/flags/global/flags_test.go (1 hunks)
  • pkg/flags/global/identity_selector.go (1 hunks)
  • pkg/flags/global_registry.go (3 hunks)
  • pkg/flags/global_registry_test.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.go

📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)

**/*.go: Use Viper for managing configuration, environment variables, and flags in CLI commands
Use interfaces for external dependencies to facilitate mocking and consider using testify/mock for creating mock implementations
All code must pass golangci-lint checks
Follow Go's error handling idioms: use meaningful error messages, wrap errors with context using fmt.Errorf("context: %w", err), and consider using custom error types for domain-specific errors
Follow standard Go coding style: use gofmt and goimports to format code, prefer short descriptive variable names, use kebab-case for command-line flags, and snake_case for environment variables
Document all exported functions, types, and methods following Go's documentation conventions
Document complex logic with inline comments in Go code
Support configuration via files, environment variables, and flags following the precedence order: flags > environment variables > config file > defaults
Provide clear error messages to users, include troubleshooting hints when appropriate, and log detailed errors for debugging

**/*.go: NEVER use fmt.Fprintf(os.Stdout/Stderr) or fmt.Println(); use data.* or ui.* functions instead
All comments must end with periods (enforced by godot linter)
Organize imports in three groups separated by blank lines, sorted alphabetically: 1) Go stdlib, 2) 3rd-party (NOT cloudposse/atmos), 3) Atmos packages; maintain aliases: cfg, log, u, errUtils
Add defer perf.Track(atmosConfig, "pkg.FuncName")() + blank line to all public functions for performance tracking; use nil if no atmosConfig param
All errors MUST be wrapped using static errors defined in errors/errors.go; use errors.Join for combining multiple errors; use fmt.Errorf with %w for adding string context; use error builder for complex errors; use errors.Is() for error checking; NEVER use dynamic errors directly
Use go.uber.org/mock/mockgen with //go:generate directives for mock generation; never create manual mocks
Keep files small...

Files:

  • pkg/flags/global/identity_selector.go
  • pkg/flags/global/flags_test.go
  • pkg/flags/global_registry_test.go
  • pkg/flags/global_registry.go
**/*_test.go

📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)

**/*_test.go: Every new feature must include comprehensive unit tests targeting >80% code coverage for all packages
Use table-driven tests for testing multiple scenarios in Go
Include integration tests for command flows and test CLI end-to-end when possible with test fixtures

**/*_test.go: Prefer unit tests with mocks over integration tests; use interfaces + dependency injection for testability; generate mocks with go.uber.org/mock/mockgen; use table-driven tests; target >80% coverage
Test behavior, not implementation; never test stub functions; avoid tautological tests; make code testable via DI; no coverage theater; remove always-skipped tests; use errors.Is() for error checking

Files:

  • pkg/flags/global/flags_test.go
  • pkg/flags/global_registry_test.go
🧠 Learnings (17)
📓 Common learnings
Learnt from: Benbentwo
Repo: cloudposse/atmos PR: 1452
File: cmd/auth_login.go:43-44
Timestamp: 2025-09-07T18:07:00.549Z
Learning: In the atmos project, the identity flag is defined as a persistent flag on the auth root command (cmd/auth.go), making it available to all auth subcommands without needing to be redefined in each individual subcommand.
Learnt from: osterman
Repo: cloudposse/atmos PR: 1686
File: docs/prd/tool-dependencies-integration.md:58-64
Timestamp: 2025-12-13T06:07:37.766Z
Learning: cloudposse/atmos: For PRD docs (docs/prd/*.md), markdownlint issues like MD040/MD010/MD034 can be handled in a separate documentation cleanup commit and should not block the current PR.
Learnt from: RoseSecurity
Repo: cloudposse/atmos PR: 1448
File: cmd/ansible.go:26-28
Timestamp: 2025-09-05T14:57:37.360Z
Learning: The Atmos codebase uses a consistent pattern for commands that delegate to external tools: `PersistentFlags().Bool("", false, doubleDashHint)` where doubleDashHint provides help text about using double dashes to separate Atmos options from native command arguments. This pattern is used across terraform, packer, helmfile, atlantis, aws, and ansible commands.
Learnt from: osterman
Repo: cloudposse/atmos PR: 1599
File: internal/exec/terraform.go:394-402
Timestamp: 2025-10-10T23:51:36.597Z
Learning: In Atmos (internal/exec/terraform.go), when adding OpenTofu-specific flags like `--var-file` for `init`, do not gate them based on command name (e.g., checking if `info.Command == "tofu"` or `info.Command == "opentofu"`) because command names don't reliably indicate the actual binary being executed (symlinks, aliases). Instead, document the OpenTofu requirement in code comments and documentation, trusting users who enable the feature (e.g., `PassVars`) to ensure their terraform command points to an OpenTofu binary.
📚 Learning: 2025-12-16T18:20:55.630Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-16T18:20:55.630Z
Learning: Applies to **/*_test.go : Test behavior, not implementation; never test stub functions; avoid tautological tests; make code testable via DI; no coverage theater; remove always-skipped tests; use errors.Is() for error checking

Applied to files:

  • pkg/flags/global/flags_test.go
  • pkg/flags/global_registry_test.go
📚 Learning: 2025-11-24T17:35:37.209Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-11-24T17:35:37.209Z
Learning: Applies to **/*_test.go : Include integration tests for command flows and test CLI end-to-end when possible with test fixtures

Applied to files:

  • pkg/flags/global/flags_test.go
  • pkg/flags/global_registry_test.go
📚 Learning: 2025-11-24T17:35:37.209Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-11-24T17:35:37.209Z
Learning: Applies to **/*_test.go : Use table-driven tests for testing multiple scenarios in Go

Applied to files:

  • pkg/flags/global/flags_test.go
📚 Learning: 2025-09-07T18:07:00.549Z
Learnt from: Benbentwo
Repo: cloudposse/atmos PR: 1452
File: cmd/auth_login.go:43-44
Timestamp: 2025-09-07T18:07:00.549Z
Learning: In the atmos project, the identity flag is defined as a persistent flag on the auth root command (cmd/auth.go), making it available to all auth subcommands without needing to be redefined in each individual subcommand.

Applied to files:

  • pkg/flags/global_registry_test.go
  • pkg/flags/global_registry.go
📚 Learning: 2025-02-18T13:18:53.146Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 1068
File: cmd/vendor_pull.go:31-31
Timestamp: 2025-02-18T13:18:53.146Z
Learning: Error checking is not required for cobra.Command.RegisterFlagCompletionFunc calls as these are static configurations done at init time.

Applied to files:

  • pkg/flags/global_registry_test.go
  • pkg/flags/global_registry.go
📚 Learning: 2025-11-24T17:35:37.209Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-11-24T17:35:37.209Z
Learning: Applies to **/*_test.go : Every new feature must include comprehensive unit tests targeting >80% code coverage for all packages

Applied to files:

  • pkg/flags/global_registry_test.go
📚 Learning: 2025-12-16T18:20:55.630Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-16T18:20:55.630Z
Learning: Applies to cmd/**/*_test.go : ALWAYS use cmd.NewTestKit(t) for cmd tests to auto-clean RootCmd state (flags, args)

Applied to files:

  • pkg/flags/global_registry_test.go
📚 Learning: 2025-11-10T03:03:31.505Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 0
File: :0-0
Timestamp: 2025-11-10T03:03:31.505Z
Learning: In the Atmos codebase, commands using the `StandardParser` flag pattern (from pkg/flags) do NOT need explicit `viper.BindPFlag()` calls in their code. The StandardParser encapsulates flag binding internally: flags are registered via `parser.RegisterFlags(cmd)` in init(), and bound via `parser.BindFlagsToViper(cmd, v)` in RunE, which internally calls viper.BindPFlag for each flag. This pattern is used throughout Atmos (e.g., cmd/toolchain/get.go, cmd/toolchain/info.go, cmd/toolchain/install.go, cmd/toolchain/path.go). Do not flag missing viper.BindPFlag calls when StandardParser is used.

Applied to files:

  • pkg/flags/global_registry_test.go
  • pkg/flags/global_registry.go
📚 Learning: 2025-12-16T18:20:55.630Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-16T18:20:55.630Z
Learning: Applies to cmd/**/*.go : Commands MUST use flags.NewStandardParser() for command-specific flags; NEVER call viper.BindEnv() or viper.BindPFlag() directly (Forbidigo enforces this); see cmd/version/version.go for reference

Applied to files:

  • pkg/flags/global_registry_test.go
  • pkg/flags/global_registry.go
📚 Learning: 2025-11-24T17:35:37.209Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-11-24T17:35:37.209Z
Learning: Applies to **/*.go : Use Viper for managing configuration, environment variables, and flags in CLI commands

Applied to files:

  • pkg/flags/global_registry.go
📚 Learning: 2025-12-13T04:37:45.831Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1686
File: cmd/toolchain/get.go:23-40
Timestamp: 2025-12-13T04:37:45.831Z
Learning: In cmd/toolchain/get.go, the get subcommand intentionally uses cobra.MaximumNArgs(1) so it works with zero args (list all tools) or one arg (a specific tool). Flags are defined via flags.NewStandardParser() with --all (bool) and --limit (int); no direct viper.BindEnv/BindPFlag calls are used.

Applied to files:

  • pkg/flags/global_registry.go
📚 Learning: 2025-11-24T17:35:37.209Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-11-24T17:35:37.209Z
Learning: Applies to cmd/**/*.go : Provide comprehensive help text for all commands and flags, include examples in command help, and follow Go's documentation conventions in Cobra command definitions

Applied to files:

  • pkg/flags/global_registry.go
📚 Learning: 2025-11-24T17:35:37.209Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-11-24T17:35:37.209Z
Learning: Applies to cmd/**/*.go : Use Cobra's recommended command structure with a root command and subcommands, implementing each command in a separate file under `cmd/` directory

Applied to files:

  • pkg/flags/global_registry.go
📚 Learning: 2025-11-24T17:35:37.209Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-11-24T17:35:37.209Z
Learning: Applies to **/*.go : Support configuration via files, environment variables, and flags following the precedence order: flags > environment variables > config file > defaults

Applied to files:

  • pkg/flags/global_registry.go
📚 Learning: 2025-01-09T22:37:01.004Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 914
File: cmd/terraform_commands.go:260-265
Timestamp: 2025-01-09T22:37:01.004Z
Learning: In the terraform commands implementation (cmd/terraform_commands.go), the direct use of `os.Args[2:]` for argument handling is intentionally preserved to avoid extensive refactoring. While it could be improved to use cobra's argument parsing, such changes should be handled in a dedicated PR to maintain focus and minimize risk.

Applied to files:

  • pkg/flags/global_registry.go
📚 Learning: 2025-09-29T15:47:10.908Z
Learnt from: aknysh
Repo: cloudposse/atmos PR: 1540
File: internal/exec/terraform_cli_args_utils.go:64-73
Timestamp: 2025-09-29T15:47:10.908Z
Learning: In the Atmos codebase, viper.BindEnv is required for CLI commands in the cmd/ package, but internal utilities can use os.Getenv directly when parsing environment variables for business logic purposes. The requirement to use viper is specific to the CLI interface layer, not all environment variable access throughout the codebase.

Applied to files:

  • pkg/flags/global_registry.go
🧬 Code graph analysis (4)
pkg/flags/global/identity_selector.go (2)
pkg/perf/perf.go (1)
  • Track (121-138)
pkg/config/const.go (1)
  • IdentityFlagDisabledValue (139-139)
pkg/flags/global/flags_test.go (1)
pkg/flags/global/identity_selector.go (2)
  • IdentitySelector (15-18)
  • NewIdentitySelector (21-28)
pkg/flags/global_registry_test.go (1)
pkg/config/const.go (1)
  • IdentityFlagDisabledValue (139-139)
pkg/flags/global_registry.go (2)
pkg/flags/global/identity_selector.go (1)
  • NewIdentitySelector (21-28)
pkg/config/const.go (1)
  • IdentityFlagDisabledValue (139-139)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Acceptance Tests (linux)
  • GitHub Check: Acceptance Tests (windows)
  • GitHub Check: Acceptance Tests (macos)
  • GitHub Check: Summary
🔇 Additional comments (7)
pkg/flags/global/identity_selector.go (1)

60-68: Clean implementation of IsDisabled() method.

The logic correctly requires both provided and the sentinel value check to prevent false positives. The documentation clearly explains when authentication is disabled, and the implementation follows the same pattern as IsInteractiveSelector().

pkg/flags/global_registry.go (2)

113-128: Solid normalization implementation.

The function correctly handles case-insensitive matching for all the false-like values (false, 0, no, off) and returns the disabled sentinel. The empty string check prevents unnecessary processing, and the default case preserves valid identity names unchanged.


86-111: Normalization consistently applied in both code paths.

Good work applying normalizeIdentityValue() when the flag is explicitly set via CLI (line 101) and when provided via environment/config (line 107). This ensures users can disable authentication regardless of how they provide the value.

pkg/flags/global/flags_test.go (1)

272-312: Comprehensive test coverage for IsDisabled().

The test cases cover all important scenarios including the critical case where the disabled sentinel is present but the flag wasn't explicitly provided (should return false). Table-driven approach makes it easy to verify behavior across different inputs.

Note: The AI summary mentions duplicate test definitions, but this appears to be a summary error—the code contains only one TestIdentitySelector_IsDisabled function as expected.

pkg/flags/global_registry_test.go (3)

13-96: Excellent test coverage for normalization behavior.

The test cases cover all the disabled value variations (false/FALSE/False/0/no/NO/off/OFF) and verify that normal identity names pass through unchanged. Creating a fresh Viper instance per test ensures proper isolation. The assertions check both the normalized value and the IsProvided() status.


98-114: Good coverage of the not-provided scenario.

This test correctly verifies that when no identity value is set in Viper, the selector returns empty value with IsProvided() false. This ensures the absence of a value is properly distinguished from explicitly setting a value.


116-163: Proper testing of explicit flag changes.

Testing the cmd.Flags().Set() path ensures that normalization works when the flag is explicitly set on the command line. The test correctly syncs to Viper to mirror real command execution behavior and verifies both normalization and the provided status.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Dec 20, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.20%. Comparing base (b12d7f6) to head (07d7f1c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1900      +/-   ##
==========================================
- Coverage   73.20%   73.20%   -0.01%     
==========================================
  Files         609      609              
  Lines       56998    57009      +11     
==========================================
+ Hits        41728    41736       +8     
- Misses      12329    12334       +5     
+ Partials     2941     2939       -2     
Flag Coverage Δ
unittests 73.20% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/flags/global/identity_selector.go 100.00% <100.00%> (ø)
pkg/flags/global_registry.go 98.64% <100.00%> (+1.45%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aknysh
Andriy Knysh (aknysh) merged commit aafe982 into main Dec 21, 2025
@aknysh
Andriy Knysh (aknysh) deleted the osterman/fix-issue-1898 branch December 21, 2025 02:18
@github-actions

Copy link
Copy Markdown

These changes were released in v1.202.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch A minor, backward compatible change size/m Medium size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Atmos identity = false does not work

2 participants