Skip to content

feat: config validation hardening - #210

Merged
thushan merged 4 commits into
mainfrom
feature/config-validation-hardening
Aug 5, 2026
Merged

feat: config validation hardening#210
thushan merged 4 commits into
mainfrom
feature/config-validation-hardening

Conversation

@thushan

@thushan thushan commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Improves the config handling and hardens some of the formatting woes and adds a validator flag to ensure configs are valid via --validate-config.

Summary by CodeRabbit

  • New Features
    • Added --validate-config to check configuration and provider profiles without starting services.
    • Validation now provides clear reports, warnings, errors and exit codes.
    • Invalid logging settings now fall back safely, with improved format, output and environment override handling.
    • Malformed profiles are reported while valid profiles continue loading.
  • Documentation
    • Added guidance for model metadata customisation, configuration validation and logging behaviour.
    • Documented model configuration paths, fallback rules and YAML formatting requirements.

@thushan thushan self-assigned this Aug 5, 2026
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The change adds configuration validation before startup, warning accessors for model and profile loading, runtime logging format and output resolution, and documentation for these behaviours.

Changes

Configuration behaviour

Layer / File(s) Summary
Configuration warning propagation
internal/adapter/registry/profile/loader.go, internal/adapter/registry/profile/factory.go, internal/adapter/unifier/model_config.go, internal/adapter/registry/profile/loader_test.go
Profile and model loaders record warnings, continue loading valid entries, clear stale warnings on reload, and expose copied warning lists.
Configuration validation command
validate.go, main.go, validate_test.go
--validate-config loads the main, model, and profile configuration, prints validation results, and exits with status 0 only when no errors or warnings exist.
Runtime logging resolution
main.go, main_test.go
Logging format and output use configured values, defaults, TTY detection, and environment overrides. Invalid values produce warnings and use defaults.
Configuration documentation
docs/content/concepts/model-unification.md, docs/content/configuration/*.md, docs/content/getting-started/installation.md
Documentation covers model metadata extraction, logging fallback behaviour, and configuration validation usage and exit statuses.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant Validation
  participant ConfigLoaders
  participant Report
  CLI->>Validation: run --validate-config
  Validation->>ConfigLoaders: load main, model, and profile configuration
  ConfigLoaders-->>Validation: configuration results and warnings
  Validation->>Report: build validation report
  Report-->>CLI: print report and return exit code
Loading

Possibly related PRs

  • thushan/olla#206: Extends model configuration warning tracking with the ConfigWarnings() accessor used by validation.
  • thushan/olla#207: Also changes model metadata configuration loading and fallback behaviour.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 summarises the main change: stronger configuration validation, including the new validation command and warning handling.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/config-validation-hardening

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/content/configuration/overview.md`:
- Line 379: Update the logging configuration documentation in
docs/content/configuration/overview.md at lines 379-379 and
docs/content/configuration/reference.md at lines 787-787 to distinguish
bootstrap logging from runtime logging: state that OLLA_FILE_OUTPUT and related
file-rotation variables configure bootstrap logger output, while logging.output:
"file" configures runtime logging alongside stdout and has no
environment-variable equivalent, being YAML-only.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: cdbe6ca5-2fec-4751-915f-588ea70d3017

📥 Commits

Reviewing files that changed from the base of the PR and between 5e27c11 and ed5a55f.

📒 Files selected for processing (12)
  • docs/content/concepts/model-unification.md
  • docs/content/configuration/overview.md
  • docs/content/configuration/reference.md
  • docs/content/getting-started/installation.md
  • internal/adapter/registry/profile/factory.go
  • internal/adapter/registry/profile/loader.go
  • internal/adapter/registry/profile/loader_test.go
  • internal/adapter/unifier/model_config.go
  • main.go
  • main_test.go
  • validate.go
  • validate_test.go

!!! warning "TTY always wins for format"
On an interactive terminal, Olla always prints pretty/text logs, no matter what `logging.format` says in the config file - so `format: "json"` in `config.yaml` (typically set for Docker/production) won't change what you see running `olla` directly in a terminal. Off a TTY (piped, Docker, a service), the configured format is used as written. Set the `OLLA_LOGGING_FORMAT` environment variable to force a format everywhere, TTY or not.

`output: "file"` adds a rotating file handler alongside stdout logging - it doesn't replace stdout. There's no environment variable for `output`; it's YAML-only.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Tracked docs files:"
git ls-files 'docs/**' | sed -n '1,120p'

echo
echo "Search for OLLA_FILE_OUTPUT and logging output mentions:"
rg -n "OLLA_(FILE_OUTPUT|LOGGING_OUTPUT)|logging\.output|output: \"file\"|file handler|rotat" docs/content/configuration || true

echo
echo "Relevant sections in overview/reference (line ranges):"
for f in docs/content/configuration/overview.md docs/content/configuration/reference.md docs/content/configuration/environment-variables.md; do
  if [ -f "$f" ]; then
    echo "--- $f ---"
    wc -l "$f"
  fi
done

Repository: thushan/olla

Length of output: 6565


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Reference relevant excerpt:"
sed -n '760,845p' docs/content/configuration/reference.md

echo
echo "Monitoring bootstrap/runtime relevant excerpt:"
sed -n '170,225p' docs/content/configuration/practices/monitoring.md

echo
echo "Python text extractor summary for logging env variable mentions:"
python3 - <<'PY'
from pathlib import Path
for p in sorted(Path('docs/content').rglob('*.md')):
    text = p.read_text()
    if 'logging.output' in text or 'OLLA_FILE_OUTPUT' in text or 'OLLA_LOGGING_OUTPUT' in text:
        lines = text.splitlines()
        print(f'--- {p} ---')
        for i, line in enumerate(lines, 1):
            if 'logging.output' in line or 'OLLA_FILE_OUTPUT' in line or 'OLLA_LOGGING_OUTPUT' in line:
                print(f'{i}: {line}')
PY

Repository: thushan/olla

Length of output: 6810


Clarify the bootstrap/runtime logging output scope.

OLLA_FILE_OUTPUT is read before YAML config loads and enables rotating bootstrap logger output, while logging.output: "file" controls runtime logging. Scope the current "no environment variable for output" and YAML-only statements to the runtime config-layer logger, and keep the bootstrap file-rotation variables separate. Do the same for docs/content/configuration/overview.md and docs/content/configuration/reference.md.

📍 Affects 2 files
  • docs/content/configuration/overview.md#L379-L379 (this comment)
  • docs/content/configuration/reference.md#L787-L787
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/content/configuration/overview.md` at line 379, Update the logging
configuration documentation in docs/content/configuration/overview.md at lines
379-379 and docs/content/configuration/reference.md at lines 787-787 to
distinguish bootstrap logging from runtime logging: state that OLLA_FILE_OUTPUT
and related file-rotation variables configure bootstrap logger output, while
logging.output: "file" configures runtime logging alongside stdout and has no
environment-variable equivalent, being YAML-only.

@thushan
thushan merged commit ccb21f7 into main Aug 5, 2026
8 checks passed
@thushan
thushan deleted the feature/config-validation-hardening branch August 5, 2026 23:56
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.

1 participant