fix: use absolute path for dev DATA_DIR default, clarify env docs #46

Merged
sneak merged 2 commits from fix/45-readme-clarify-env-and-datadir into main 2026-03-17 12:48:53 +01:00
Collaborator

Closes #45.

Problem

  1. The README didn't clearly explain what WEBHOOKER_ENVIRONMENT=dev vs prod actually changes.
  2. The dev-mode default for DATA_DIR was ./data — a relative path whose meaning depends on the working directory. There's no reason to use a relative path even in development.

Changes

Code (internal/config/config.go)

  • Replace the dev default DATA_DIR from ./data to $XDG_DATA_HOME/webhooker (falling back to $HOME/.local/share/webhooker). This follows the XDG Base Directory Specification and ensures the data directory is always an absolute path regardless of the working directory.
  • Add devDataDir() helper that resolves the XDG path, with a /tmp/webhooker last-resort fallback if $HOME can't be determined.

Tests (internal/config/config_test.go)

  • TestDevDataDir: verifies XDG_DATA_HOME is respected, HOME fallback works, and the result is always absolute.
  • TestDevDefaultDataDirIsAbsolute: integration test that creates a full Config via fx and asserts the dev default DataDir is absolute.

README

  • Add a table documenting exactly what dev vs prod changes: DATA_DIR default, CORS policy, and session cookie Secure flag.
  • Clarify that log format and security headers are independent of the environment setting.
  • Update the DATA_DIR default in the configuration variable table.
Closes #45. ## Problem 1. The README didn't clearly explain what `WEBHOOKER_ENVIRONMENT=dev` vs `prod` actually changes. 2. The dev-mode default for `DATA_DIR` was `./data` — a relative path whose meaning depends on the working directory. There's no reason to use a relative path even in development. ## Changes ### Code (`internal/config/config.go`) - Replace the dev default `DATA_DIR` from `./data` to `$XDG_DATA_HOME/webhooker` (falling back to `$HOME/.local/share/webhooker`). This follows the XDG Base Directory Specification and ensures the data directory is always an absolute path regardless of the working directory. - Add `devDataDir()` helper that resolves the XDG path, with a `/tmp/webhooker` last-resort fallback if `$HOME` can't be determined. ### Tests (`internal/config/config_test.go`) - `TestDevDataDir`: verifies XDG_DATA_HOME is respected, HOME fallback works, and the result is always absolute. - `TestDevDefaultDataDirIsAbsolute`: integration test that creates a full Config via fx and asserts the dev default DataDir is absolute. ### README - Add a table documenting exactly what `dev` vs `prod` changes: DATA_DIR default, CORS policy, and session cookie Secure flag. - Clarify that log format and security headers are independent of the environment setting. - Update the DATA_DIR default in the configuration variable table.
clawbot added 1 commit 2026-03-17 11:30:54 +01:00
fix: use absolute path for dev DATA_DIR default, clarify env docs
All checks were successful
check / check (push) Successful in 1m1s
ec92c2bdd2
Change the dev-mode DATA_DIR default from the relative path ./data to
$XDG_DATA_HOME/webhooker (falling back to $HOME/.local/share/webhooker).
This ensures the application's data directory does not depend on the
working directory.

Add a table to the README that clearly documents what WEBHOOKER_ENVIRONMENT
actually controls: DATA_DIR default, CORS policy, and session cookie
Secure flag.

Add tests for devDataDir() and verify the dev default is always absolute.
clawbot added the needs-review label 2026-03-17 11:31:44 +01:00
clawbot reviewed 2026-03-17 11:35:56 +01:00
clawbot left a comment
Author
Collaborator

Review: PR #46 — fix: use absolute path for dev DATA_DIR default, clarify env docs

Policy Divergences

No policy violations found.

All external references remain pinned by sha256 hash. No modifications to .golangci.yml, Makefile, Dockerfile, CI config, or test assertions. No new migration files. No secrets committed.

Requirements Checklist (issue #45)

Requirement Status
Document what dev vs prod actually changes Met — new table in README clearly lists DATA_DIR default, CORS policy, and session cookie Secure flag differences
Clarify that other settings (log format, security headers) are independent of env Met — explicit note added below the table
Replace relative ./data dev default with an absolute path Met — devDataDir() uses $XDG_DATA_HOME/webhooker$HOME/.local/share/webhooker/tmp/webhooker fallback chain, all absolute
Update DATA_DIR default in README config table Met — updated to $XDG_DATA_HOME/webhooker

Code Evaluation

  • devDataDir() — Clean XDG Base Directory Specification implementation. Three-tier fallback (XDG_DATA_HOME → HOME → /tmp) ensures an absolute path even in degenerate environments. Uses os.UserHomeDir() rather than raw $HOME which is more portable.
  • TestsTestDevDataDir covers XDG override, HOME fallback, and absolute-path invariant. TestDevDefaultDataDirIsAbsolute is a full integration test through the fx DI graph verifying the end-to-end default. Both are thorough.
  • README — The behavior table is accurate and the config variable table is consistent with the new code.
  • Scope — Tightly scoped to exactly what the issue requested. No scope creep.

Build Result

docker build . passed. All tests pass (config, database, delivery, handlers, logger, middleware, session). Lint and fmt-check clean.

Verdict: PASS

PR is rebased on main (already up to date). Build verified post-rebase. Fully addresses all requirements in issue #45 with no policy violations.

## Review: [PR #46](https://git.eeqj.de/sneak/webhooker/pulls/46) — fix: use absolute path for dev DATA_DIR default, clarify env docs ### Policy Divergences No policy violations found. All external references remain pinned by sha256 hash. No modifications to `.golangci.yml`, Makefile, Dockerfile, CI config, or test assertions. No new migration files. No secrets committed. ### Requirements Checklist ([issue #45](https://git.eeqj.de/sneak/webhooker/issues/45)) | Requirement | Status | |---|---| | Document what `dev` vs `prod` actually changes | ✅ Met — new table in README clearly lists DATA_DIR default, CORS policy, and session cookie Secure flag differences | | Clarify that other settings (log format, security headers) are independent of env | ✅ Met — explicit note added below the table | | Replace relative `./data` dev default with an absolute path | ✅ Met — `devDataDir()` uses `$XDG_DATA_HOME/webhooker` → `$HOME/.local/share/webhooker` → `/tmp/webhooker` fallback chain, all absolute | | Update DATA_DIR default in README config table | ✅ Met — updated to `$XDG_DATA_HOME/webhooker` | ### Code Evaluation - **`devDataDir()`** — Clean XDG Base Directory Specification implementation. Three-tier fallback (XDG_DATA_HOME → HOME → /tmp) ensures an absolute path even in degenerate environments. Uses `os.UserHomeDir()` rather than raw `$HOME` which is more portable. - **Tests** — `TestDevDataDir` covers XDG override, HOME fallback, and absolute-path invariant. `TestDevDefaultDataDirIsAbsolute` is a full integration test through the fx DI graph verifying the end-to-end default. Both are thorough. - **README** — The behavior table is accurate and the config variable table is consistent with the new code. - **Scope** — Tightly scoped to exactly what the issue requested. No scope creep. ### Build Result `docker build .` passed. All tests pass (config, database, delivery, handlers, logger, middleware, session). Lint and fmt-check clean. ### Verdict: **PASS** PR is rebased on `main` (already up to date). Build verified post-rebase. Fully addresses all requirements in [issue #45](https://git.eeqj.de/sneak/webhooker/issues/45) with no policy violations.
clawbot added merge-ready and removed needs-review labels 2026-03-17 11:36:44 +01:00
sneak was assigned by clawbot 2026-03-17 11:36:51 +01:00
sneak added 1 commit 2026-03-17 12:31:28 +01:00
Merge branch 'main' into fix/45-readme-clarify-env-and-datadir
All checks were successful
check / check (push) Successful in 1m1s
b1343364a3
Owner

there is no need for a separate dev/prod data dir - use /var/lib/<appname>

there is no need for a separate dev/prod data dir - use `/var/lib/<appname>`
sneak removed their assignment 2026-03-17 12:37:48 +01:00
clawbot was assigned by sneak 2026-03-17 12:37:48 +01:00
clawbot added needs-rework and removed merge-ready labels 2026-03-17 12:38:19 +01:00
clawbot force-pushed fix/45-readme-clarify-env-and-datadir from b1343364a3 to 93968b6f10 2026-03-17 12:43:47 +01:00 Compare
Author
Collaborator

Rework Summary

Addressed review feedback on PR #46 (closing issue #45).

Changes

Per sneak's review: removed the separate dev/prod DATA_DIR logic entirely. Both environments now use the same default: /var/lib/webhooker.

internal/config/config.go:

  • Removed devDataDir() function (XDG-based path resolution)
  • Removed path/filepath import (no longer needed)
  • Replaced environment-conditional default with a single unconditional default: /var/lib/webhooker

internal/config/config_test.go:

  • Removed TestDevDataDir (tested the removed function)
  • Replaced TestDevDefaultDataDirIsAbsolute with TestDefaultDataDir — verifies the default is /var/lib/webhooker for all environment values (unset, dev, prod)
  • Removed unused path/filepath import

Dockerfile:

  • Changed data directory from /data to /var/lib/webhooker

README.md:

  • Removed Default DATA_DIR row from the dev/prod differences table (no longer different)
  • Updated DATA_DIR default in config variables table to /var/lib/webhooker
  • Updated Docker run example volume mount to /var/lib/webhooker
  • Updated all remaining references from /data to /var/lib/webhooker

Build

docker build . passes — all tests pass, lint clean, fmt clean.

## Rework Summary Addressed review feedback on [PR #46](https://git.eeqj.de/sneak/webhooker/pulls/46) (closing [issue #45](https://git.eeqj.de/sneak/webhooker/issues/45)). ### Changes Per sneak's review: removed the separate dev/prod DATA_DIR logic entirely. Both environments now use the same default: `/var/lib/webhooker`. **`internal/config/config.go`:** - Removed `devDataDir()` function (XDG-based path resolution) - Removed `path/filepath` import (no longer needed) - Replaced environment-conditional default with a single unconditional default: `/var/lib/webhooker` **`internal/config/config_test.go`:** - Removed `TestDevDataDir` (tested the removed function) - Replaced `TestDevDefaultDataDirIsAbsolute` with `TestDefaultDataDir` — verifies the default is `/var/lib/webhooker` for all environment values (unset, dev, prod) - Removed unused `path/filepath` import **`Dockerfile`:** - Changed data directory from `/data` to `/var/lib/webhooker` **`README.md`:** - Removed `Default DATA_DIR` row from the dev/prod differences table (no longer different) - Updated DATA_DIR default in config variables table to `/var/lib/webhooker` - Updated Docker run example volume mount to `/var/lib/webhooker` - Updated all remaining references from `/data` to `/var/lib/webhooker` ### Build `docker build .` passes — all tests pass, lint clean, fmt clean.
clawbot added needs-review and removed needs-rework labels 2026-03-17 12:45:01 +01:00
clawbot reviewed 2026-03-17 12:47:31 +01:00
clawbot left a comment
Author
Collaborator

Review: PR #46 — fix: use absolute path for dev DATA_DIR default, clarify env docs (post-rework)

Policy Divergences

None. No modifications to .golangci.yml, Makefile, CI config, or test assertions. All external references remain pinned by sha256 hash. Only 4 files changed: Dockerfile, README.md, internal/config/config.go, internal/config/config_test.go.

Requirements Checklist

Requirement Status
Issue #45: Document what dev vs prod actually changes New table in README lists CORS policy and session cookie Secure flag differences
Issue #45: Fix relative path for data dir ./data replaced with /var/lib/webhooker
sneak's rework feedback: no separate dev/prod data dir, use /var/lib/<appname> Removed devDataDir(), removed environment-conditional logic, single unconditional default /var/lib/webhooker for all environments

Rework Verification

sneak's feedback was: "there is no need for a separate dev/prod data dir - use /var/lib/<appname>"

The rework correctly:

  • Removed the devDataDir() function and its XDG-based path resolution
  • Removed the path/filepath import that was only needed for XDG logic
  • Replaced the if s.IsProd() { ... } else { ... } conditional with a single unconditional default: /var/lib/webhooker
  • Removed the "Default DATA_DIR" row from the dev/prod differences table (since there's no longer a difference)
  • Updated Dockerfile from /data to /var/lib/webhooker (directory creation, ownership)
  • Updated all README references: config variables table, Docker run example, Docker section description
  • No stale references to ./data or /data remain anywhere in the codebase

Code Evaluation

  • config.go — Clean and simple. The default is set unconditionally when DATA_DIR env var is empty. Comment explains the behavior clearly.
  • config_test.goTestDefaultDataDir covers all three environment settings (unset, dev, prod) and asserts /var/lib/webhooker for each. Uses fx DI graph for realistic integration testing. No weakened assertions.
  • Dockerfile — Correctly creates /var/lib/webhooker and sets ownership. Comment updated.
  • README.md — Dev/prod behavior table is accurate (only CORS and session cookie Secure differ). Config variables table shows the correct default. Docker run example and Docker section description updated consistently.

Unaddressed Human Comments

None. sneak's only comment requested the unified data dir, which the rework fully addresses. No further human comments after the rework.

Build Result

docker build . passed. All tests pass, lint clean, fmt clean.

Verdict: PASS

The rework cleanly addresses sneak's feedback. Both dev and prod now use /var/lib/webhooker as the default DATA_DIR with no conditional logic. All references updated consistently across code, tests, Dockerfile, and README.

## Review: [PR #46](https://git.eeqj.de/sneak/webhooker/pulls/46) — fix: use absolute path for dev DATA_DIR default, clarify env docs (post-rework) ### Policy Divergences None. No modifications to `.golangci.yml`, Makefile, CI config, or test assertions. All external references remain pinned by sha256 hash. Only 4 files changed: `Dockerfile`, `README.md`, `internal/config/config.go`, `internal/config/config_test.go`. ### Requirements Checklist | Requirement | Status | |---|---| | [Issue #45](https://git.eeqj.de/sneak/webhooker/issues/45): Document what `dev` vs `prod` actually changes | ✅ New table in README lists CORS policy and session cookie Secure flag differences | | [Issue #45](https://git.eeqj.de/sneak/webhooker/issues/45): Fix relative path for data dir | ✅ `./data` replaced with `/var/lib/webhooker` | | sneak's rework feedback: no separate dev/prod data dir, use `/var/lib/<appname>` | ✅ Removed `devDataDir()`, removed environment-conditional logic, single unconditional default `/var/lib/webhooker` for all environments | ### Rework Verification sneak's feedback was: *"there is no need for a separate dev/prod data dir - use `/var/lib/<appname>`"* The rework correctly: - Removed the `devDataDir()` function and its XDG-based path resolution - Removed the `path/filepath` import that was only needed for XDG logic - Replaced the `if s.IsProd() { ... } else { ... }` conditional with a single unconditional default: `/var/lib/webhooker` - Removed the "Default DATA_DIR" row from the dev/prod differences table (since there's no longer a difference) - Updated Dockerfile from `/data` to `/var/lib/webhooker` (directory creation, ownership) - Updated all README references: config variables table, Docker run example, Docker section description - No stale references to `./data` or `/data` remain anywhere in the codebase ### Code Evaluation - **`config.go`** — Clean and simple. The default is set unconditionally when `DATA_DIR` env var is empty. Comment explains the behavior clearly. - **`config_test.go`** — `TestDefaultDataDir` covers all three environment settings (unset, dev, prod) and asserts `/var/lib/webhooker` for each. Uses fx DI graph for realistic integration testing. No weakened assertions. - **`Dockerfile`** — Correctly creates `/var/lib/webhooker` and sets ownership. Comment updated. - **`README.md`** — Dev/prod behavior table is accurate (only CORS and session cookie Secure differ). Config variables table shows the correct default. Docker run example and Docker section description updated consistently. ### Unaddressed Human Comments None. sneak's only comment requested the unified data dir, which the rework fully addresses. No further human comments after the rework. ### Build Result `docker build .` **passed**. All tests pass, lint clean, fmt clean. ### Verdict: **PASS** The rework cleanly addresses sneak's feedback. Both dev and prod now use `/var/lib/webhooker` as the default DATA_DIR with no conditional logic. All references updated consistently across code, tests, Dockerfile, and README.
clawbot added merge-ready and removed needs-review labels 2026-03-17 12:48:05 +01:00
clawbot removed their assignment 2026-03-17 12:48:05 +01:00
sneak was assigned by clawbot 2026-03-17 12:48:05 +01:00
sneak merged commit f003ec7141 into main 2026-03-17 12:48:53 +01:00
sneak deleted branch fix/45-readme-clarify-env-and-datadir 2026-03-17 12:48:53 +01:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/webhooker#46