misc: add default value for relay auth secret parsing#41
Merged
sheensantoscapadngan merged 1 commit intomainfrom Oct 21, 2025
Merged
Conversation
x032205
approved these changes
Oct 21, 2025
Contributor
There was a problem hiding this comment.
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-secretmust be provided wheninstanceType == "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
1 file reviewed, no comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description 📣
Type ✨
Tests 🛠️
# Here's some code block to paste some code snippets