Skip to content

Conversation

@mikemechanic1337
Copy link

@mikemechanic1337 mikemechanic1337 commented Sep 23, 2025

Summary

  • Closes fides init does not have a --opt-out flag #4703
  • add --opt-out flag to fides init so non-interactive setups can disable analytics
  • guard against mixing --opt-in/--opt-out and thread the new option through config creation
  • extend analytics consent unit tests and update the changelog entry

Testing

  • pytest tests/ctl/core/config/test_create.py

Manual Verification

  1. Ensure Docker Desktop is running and copy example.env to .env if needed.
  2. Launch the dev stack through nox and drop into the webserver container shell: nox -s dev -- shell. Once the shell opens, run:
    • mkdir -p /tmp/fides-init-check && cd /tmp/fides-init-check
    • fides init --opt-out
    • grep analytics_opt_out .fides/fides.toml (should read true)
    • fides init --opt-in --opt-out (fails with "--opt-in and --opt-out cannot be used together")
    • exit to leave the container shell.
  3. Execute the control-plane unit tests via nox: nox -s pytest -- ctl-unit. (This covers tests/ctl/core/config/test_create.py; alternatively run the file directly inside the container if preferred.)
  4. Tear everything down when finished: nox -s teardown -- volumes.

@vercel
Copy link

vercel bot commented Sep 23, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
fides-privacy-center Ignored Ignored Sep 24, 2025 0:33am

@vercel
Copy link

vercel bot commented Sep 23, 2025

Someone is attempting to deploy a commit to the Ethyca Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Summary

This PR adds a --opt-out flag to the fides init command, enabling non-interactive setups to disable analytics collection. The implementation includes proper validation to prevent conflicting flags (--opt-in and --opt-out cannot be used together) and threads the new parameter through the configuration creation process.

Key changes include:

  • Added --opt-out CLI flag with help text and validation logic
  • Updated request_analytics_consent() to handle both opt_in and opt_out parameters
  • Enhanced parameter threading in create_and_update_config_file()
  • Added comprehensive test coverage for all new functionality and edge cases
  • Updated changelog entry to document the new feature

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk
  • The implementation is straightforward with proper validation, comprehensive test coverage, and follows existing patterns. No security concerns or breaking changes identified.
  • No files require special attention - all changes are well-implemented and tested

Important Files Changed

File Analysis

Filename        Score        Overview
src/fides/cli/commands/ungrouped.py 4/5 Added --opt-out flag to fides init command with proper validation against conflicting --opt-in flag
src/fides/cli/utils.py 3/5 Updated analytics consent logic to handle both opt-in and opt-out parameters with validation
tests/ctl/core/config/test_create.py 4/5 Added comprehensive test coverage for new opt-out flag functionality and edge cases

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as fides init
    participant Validation as Flag Validation
    participant Utils as request_analytics_consent
    participant Config as FidesConfig
    participant EnvVar as Environment

    User->>CLI: fides init --opt-out
    CLI->>Validation: Check opt_in and opt_out flags
    alt Both flags provided
        Validation->>User: Error: cannot use both flags
    else Only opt-out provided
        CLI->>Utils: request_analytics_consent(opt_out=True)
        Utils->>EnvVar: Check FIDES__USER__ANALYTICS_OPT_OUT
        alt Environment variable set to true
            EnvVar->>Config: Set analytics_opt_out = True
            Config->>CLI: Return config
        else No environment override
            Utils->>Config: Set analytics_opt_out = True
            Config->>CLI: Return config (no prompt)
        end
    else Only opt-in provided
        CLI->>Utils: request_analytics_consent(opt_in=True)  
        Utils->>Config: Set analytics_opt_out = False
        Config->>CLI: Return config (no prompt)
    else No flags provided
        CLI->>Utils: request_analytics_consent()
        Utils->>User: Prompt for consent
        User->>Utils: Response
        Utils->>Config: Set analytics_opt_out accordingly
        Config->>CLI: Return config
    end
    CLI->>User: Continue initialization
Loading

5 files reviewed, 1 comment

Edit Code Review Bot Settings | Greptile

Comment on lines +166 to +167
if opt_in:
config.user.analytics_opt_out = False
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Logic error: when opt_in=True, analytics_opt_out should be False, not True.

Suggested change
if opt_in:
config.user.analytics_opt_out = False
if opt_in:
config.user.analytics_opt_out = False

Copy link
Author

Choose a reason for hiding this comment

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

Good catch—this reflects the intended behavior. Applied your suggestion in 6bd3a08.

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.

fides init does not have a --opt-out flag

1 participant