Skip to content

misc: add default value for relay auth secret parsing#41

Merged
sheensantoscapadngan merged 1 commit intomainfrom
misc/add-default-value-for-relay-auth-secret-parsing
Oct 21, 2025
Merged

misc: add default value for relay auth secret parsing#41
sheensantoscapadngan merged 1 commit intomainfrom
misc/add-default-value-for-relay-auth-secret-parsing

Conversation

@sheensantoscapadngan
Copy link
Member

Description 📣

Type ✨

  • Bug fix
  • New feature
  • Improvement
  • Breaking change
  • Documentation

Tests 🛠️

# Here's some code block to paste some code snippets

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

Changed relay-auth-secret parsing in the relaySystemdInstallCmd from GetCmdFlagOrEnv to GetCmdFlagOrEnvWithDefaultValue with an empty string default.

Key changes:

  • Line 204: Function call now includes "" as the default value parameter
  • Behavior: Previously would error if flag/env not found; now returns empty string and delegates validation to line 209
  • Validation logic (line 209-211) remains intact and enforces that relay-auth-secret must be provided when instanceType == "instance"

Impact:

  • Fixes parsing logic by preventing premature error before type-specific validation can run
  • Makes optional secrets truly optional for non-instance relay types while maintaining security requirements for instance types

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change improves error handling logic by allowing the relay-auth-secret to be optional (empty string default) for non-instance relay types, while maintaining strict validation for instance types through explicit checking on line 209. The function behavior is well-understood, security validation remains intact, and the change is minimal and focused
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/cmd/relay.go 5/5 Changed relay-auth-secret parsing to use default value function with empty string fallback, maintaining validation logic for instance type

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as relay systemd install
    participant Util as GetCmdFlagOrEnvWithDefaultValue
    participant Validator as Validation Logic
    participant Service as InstallRelaySystemdService

    User->>CLI: Execute install command
    CLI->>Util: Parse relay-auth-secret flag/env
    Util->>Util: Check flag value
    alt Flag not empty
        Util-->>CLI: Return flag value
    else Flag empty
        Util->>Util: Check env RELAY_AUTH_SECRET_ENV_NAME
        alt Env not empty
            Util-->>CLI: Return env value
        else Env empty
            Util-->>CLI: Return empty string (default)
        end
    end
    CLI->>Validator: Check instanceType and relayAuthSecret
    alt instanceType == "instance" && relayAuthSecret == ""
        Validator-->>User: Error: relay-auth-secret required for instance type
    else instanceType != "instance" or relayAuthSecret provided
        CLI->>Service: Install with relayAuthSecret
        Service-->>User: Service installed successfully
    end
Loading

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@sheensantoscapadngan sheensantoscapadngan merged commit b89115e into main Oct 21, 2025
4 checks passed
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