Skip to content

Add a settings loader - #2

Open
JohnCampionJr wants to merge 1 commit into
mainfrom
feat/settings-loader
Open

Add a settings loader#2
JohnCampionJr wants to merge 1 commit into
mainfrom
feat/settings-loader

Conversation

@JohnCampionJr

@JohnCampionJr JohnCampionJr commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

User description

Reads simple key=value settings files.

Unknown keys are ignored deliberately, so an older binary can read a file written by a newer one without failing. Defaults retries to 3.


Generated description

Below is a concise technical summary of the changes proposed in this PR:
Add a config.Load settings loader that parses simple key=value files into Settings, applying defaults and ignoring unknown keys for forward compatibility. Cover key parsing and comment handling with focused tests.

Latest Contributors(1)
UserCommitDate
john@brightshore.ioAdd a settings loaderAugust 27, 2026
Review this PR on Baz | Customize your next review

Summary by cubic

Adds a config package that loads simple key=value settings files. Unknown keys are ignored so older binaries can read newer files, and retries defaults to 3.

Written for commit 1f03088. Summary will update on new commits.

Review in cubic

Note

Add config.Load to parse key=value settings files

Adds a Settings struct (Name, Retries, Verbose) and a Load(path) function that reads simple key=value files, skipping blank lines and # comments. Recognized keys are name, retries (parsed via strconv.Atoi), and verbose (set true only when value equals "true"); unknown keys are ignored. Retries defaults to 3. Includes tests for reading keys and ignoring comments.

  • Risk: on retries parse failure, Retries is set to the Atoi zero-value (0) rather than the default 3; on file read error, Load returns the default-initialized Settings (Retries=3) alongside the error.
📊 Macroscope summarized 1f03088. 1 file reviewed, 3 issues evaluated, 0 issues filtered, 2 comments posted

🗂️ Filtered Issues

Reads key=value files. Unknown keys are ignored so an older binary can read a
newer file without failing.
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4c5c1b61-4f7e-4500-ba61-a81eb52db891

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

Comment thread internal/config/load.go
Comment on lines +38 to +41
n, _ := strconv.Atoi(strings.TrimSpace(value))
s.Retries = n
case "verbose":
s.Verbose = strings.TrimSpace(value) == "true"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High config/load.go:38

Load silently accepts invalid values: verbose=ture or verbose=yes returns Settings{Verbose:false} with a nil error, while retries=three returns Settings{Retries:0} with a nil error, overriding the default of 3. The Atoi error is discarded and non-true verbose values are treated as false; return parsing errors instead.

Suggested change
n, _ := strconv.Atoi(strings.TrimSpace(value))
s.Retries = n
case "verbose":
s.Verbose = strings.TrimSpace(value) == "true"
n, err := strconv.Atoi(strings.TrimSpace(value))
if err != nil {
return s, err
}
s.Retries = n
case "verbose":
v := strings.TrimSpace(value)
if v != "true" && v != "false" {
return s, strconv.ErrSyntax
}
s.Verbose = v == "true"
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @internal/config/load.go around lines 38-41:

`Load` silently accepts invalid values: `verbose=ture` or `verbose=yes` returns `Settings{Verbose:false}` with a nil error, while `retries=three` returns `Settings{Retries:0}` with a nil error, overriding the default of `3`. The `Atoi` error is discarded and non-`true` verbose values are treated as false; return parsing errors instead.

Comment thread internal/config/load.go
continue
}

key, value, _ := strings.Cut(line, "=")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium config/load.go:33

A malformed known-key line such as name is accepted as valid input and clears Settings.Name, so Load reports success without letting callers distinguish it from name=. The found result from strings.Cut is ignored; validate it and return a parse error when = is missing.

🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @internal/config/load.go around line 33:

A malformed known-key line such as `name` is accepted as valid input and clears `Settings.Name`, so `Load` reports success without letting callers distinguish it from `name=`. The `found` result from `strings.Cut` is ignored; validate it and return a parse error when `=` is missing.

@githail

githail Bot commented Aug 27, 2026

Copy link
Copy Markdown

@coderabbitai review

@githail
githail Bot requested a lite review from Copilot August 27, 2026 04:41
@githail

githail Bot commented Aug 27, 2026

Copy link
Copy Markdown

@macroscopeapp review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1f03088834

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/config/load.go
Comment on lines +38 to +39
n, _ := strconv.Atoi(strings.TrimSpace(value))
s.Retries = n

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject invalid retry counts instead of silently using zero

When retries is missing a value, nonnumeric, or overflows an int, strconv.Atoi returns an error that is discarded, and Retries is then set to zero. This silently replaces the documented default of 3 (or an earlier valid value), while Load returns a nil error, potentially disabling retries because of a malformed setting; propagate the parsing error or preserve the previous/default value.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Merged into Invalid retries value silently becomes 0, overriding the documented default of 3 (internal/config/load.go:38), also reported by macroscopeapp, chatgpt-codex-connector, copilot-pull-request-reviewer.

Resolving this thread as a duplicate — the finding itself is not dismissed, and reopening this thread is the right move if the merge is wrong.

See the consolidated review: #2 (comment)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Merged into Invalid retries value silently becomes 0, overriding the documented default of 3 (internal/config/load.go:38), also reported by macroscopeapp, chatgpt-codex-connector, copilot-pull-request-reviewer.

Resolving this thread as a duplicate — the finding itself is not dismissed, and reopening this thread is the right move if the merge is wrong.

See the consolidated review: #2 (comment)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Merged into Invalid retries value silently resets to 0, overriding the documented default of 3 (internal/config/load.go:38), also reported by macroscopeapp, chatgpt-codex-connector, copilot-pull-request-reviewer.

Resolving this thread as a duplicate — the finding itself is not dismissed, and reopening this thread is the right move if the merge is wrong.

See the consolidated review: #2 (comment)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds an internal/config package for loading simple key=value settings files into a Settings struct, with defaults and forward-compatible handling of unknown keys.

Changes:

  • Introduces config.Settings and config.Load(path) to parse settings files, skip blank lines / # comments, and ignore unknown keys.
  • Applies a default for Retries (3) and parses retries/verbose/name values from the file.
  • Adds initial unit tests covering key reading and comment ignoring.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
internal/config/load.go Implements Settings and Load to parse key=value settings with defaults and ignored unknown keys.
internal/config/load_test.go Adds tests for parsing known keys and skipping # comment lines.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/config/load.go
Comment on lines +37 to +39
case "retries":
n, _ := strconv.Atoi(strings.TrimSpace(value))
s.Retries = n

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Merged into Invalid retries value silently becomes 0, overriding the documented default of 3 (internal/config/load.go:38), also reported by macroscopeapp, chatgpt-codex-connector, copilot-pull-request-reviewer.

Resolving this thread as a duplicate — the finding itself is not dismissed, and reopening this thread is the right move if the merge is wrong.

See the consolidated review: #2 (comment)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Merged into Invalid retries value silently becomes 0, overriding the documented default of 3 (internal/config/load.go:38), also reported by macroscopeapp, chatgpt-codex-connector, copilot-pull-request-reviewer.

Resolving this thread as a duplicate — the finding itself is not dismissed, and reopening this thread is the right move if the merge is wrong.

See the consolidated review: #2 (comment)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Merged into Invalid retries value silently resets to 0, overriding the documented default of 3 (internal/config/load.go:38), also reported by macroscopeapp, chatgpt-codex-connector, copilot-pull-request-reviewer.

Resolving this thread as a duplicate — the finding itself is not dismissed, and reopening this thread is the right move if the merge is wrong.

See the consolidated review: #2 (comment)

Comment thread internal/config/load.go
"strings"
)

// Settings holds what a settings file described.
Comment on lines +30 to +35
func TestLoadIgnoresComments(t *testing.T) {
got, _ := Load(write(t, "# a comment\nname = app\n"))
if got.Name != "app" {
t.Errorf("got %+v", got)
}
}
@githail

githail Bot commented Aug 27, 2026

Copy link
Copy Markdown

Review reconciled — 5 findings from 3 reviewers

Findings

MAJOR — Invalid retries value silently resets to 0, overriding the documented default of 3 · internal/config/load.go:38 · macroscopeapp, chatgpt-codex-connector, copilot-pull-request-reviewer
In the retries case, n, _ := strconv.Atoi(strings.TrimSpace(value)) discards the parse error and unconditionally assigns s.Retries = n. A missing, non-numeric, or overflowing value (e.g. retries=three, retries=) yields n == 0, silently replacing the default of 3 (set at line 20) while Load still returns a nil error. Three independent reviewers converged on this same defect from the same two lines (38-39).

MINOR — Non-"true" verbose values (typos, "yes", "1") are silently treated as false · internal/config/load.go:41 · macroscopeapp
s.Verbose = strings.TrimSpace(value) == "true" accepts any string. verbose=ture or verbose=yes matches the known verbose key and returns Settings{Verbose:false} with a nil error, so an operator's typo or non-canonical boolean silently fails to enable verbose mode instead of surfacing a parse error. This was bundled with the retries defect in the same macroscopeapp comment but is a separate mechanism (different field, different line, lower blast radius) — no other reviewer flagged it independently, so it is kept as its own cluster rather than merged into the retries cluster.

MINOR — A known-key line without = is silently accepted and clears the field · internal/config/load.go:33 · macroscopeapp
key, value, _ := strings.Cut(line, "=") discards the found bool. A malformed line consisting of just name (no =) is parsed as key="name", value="", matches the known name case, and silently sets Settings.Name = "" with Load returning a nil error — indistinguishable from a deliberate name= line.

MINOR — No test exercises the retries default or an invalid retries value · internal/config/load_test.go:35 · copilot-pull-request-reviewer
TestLoadReadsKeys and TestLoadIgnoresComments never assert Retries == 3 on an empty/default file, nor feed an invalid retries value. The green test check run therefore is not a signal against config-load-retries-atoi-error-discarded — it never ran a case that would catch it.

NIT — Settings doc comment reads awkwardly in the past tense · internal/config/load.go:10 · copilot-pull-request-reviewer
"Settings holds what a settings file described." reads more naturally as "...a settings file describes" (present tense), since the file describes the settings whenever it is read, not just at some past point.

Coverage

Absent: coderabbitai, baz-reviewer — this verdict is incomplete, not clean.
Not verified: All inline comments and reviews carried commit_id/original_commit_id 1f03088, matching the requested sha, so no filtering was needed and nothing was excluded on that basis. No reviewer claimed a finding recurred at additional locations, so there was nothing to re-verify or drop on that count. Four githail[bot] replies already present on the codex and copilot retries threads are prior consolidation output from an earlier run of this same reconciliation, not new reviewer evidence — they were read but not treated as findings/verifications. Did not independently run the test suite or the Correctness Check locally; relied on the recorded check-run conclusions (test: success, Macroscope Correctness Check: neutral), neither of which asserts behavior contradicting any cluster above.

Verdict: incomplete

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants