Skip to content

aperturedb: add yaml struct tags to fix config file key mismatches#235

Open
maml wants to merge 1 commit into
lightninglabs:masterfrom
maml:sqlite-yaml-tags
Open

aperturedb: add yaml struct tags to fix config file key mismatches#235
maml wants to merge 1 commit into
lightninglabs:masterfrom
maml:sqlite-yaml-tags

Conversation

@maml
Copy link
Copy Markdown

@maml maml commented Apr 18, 2026

Summary

Adds missing yaml: struct tags to SqliteConfig and PostgresConfig so that YAML config file keys are correctly mapped when aperture is configured via aperture.yaml.

Problem

goccy/go-yaml (used in aperture.go) falls back to the lowercased field name when no yaml: tag is present. This caused silent mismatches:

Struct field go-flags key YAML fallback sample-conf.yaml key Result
SqliteConfig.DatabaseFileName dbfile databasefilename dbfile Never read — SQLite fails to open
SqliteConfig.SkipMigrations skipmigrations skipmigrations skipmigrations Coincidental match (no change needed)
PostgresConfig.MaxOpenConnections maxconnections maxopenconnections maxconnections Never read — pool size silently wrong
PostgresConfig.SkipMigrations skipmigrations skipmigrations skipmigrations Coincidental match
PostgresConfig.RequireSSL requiressl requiressl requireSSL Never read — SSL silently disabled

Fix

Added yaml: tags matching the documented config keys:

  • SqliteConfig.DatabaseFileName: yaml:"dbfile"
  • PostgresConfig.MaxOpenConnections: yaml:"maxconnections"
  • PostgresConfig.RequireSSL: yaml:"requireSSL" (matches sample-conf.yaml:168)
  • PostgresConfig.SkipMigrations and SqliteConfig.SkipMigrations: yaml:"skipmigrations" (no behaviour change, added for explicitness and rename safety)

Test plan

  • Configure aperture with dbfile: /path/to/db in YAML; confirm SQLite opens correctly.
  • Configure with maxconnections: 5; confirm pool size is respected.
  • Configure with requireSSL: true; confirm TLS connection is required.

Aperture parses its config file with goccy/go-yaml, which falls back to
the lowercased struct field name when no yaml tag is present.

Two fields had a mismatch between their go-flags `long:` tag (which
documents the YAML key in sample-conf.yaml) and the goccy/go-yaml
fallback name derived from the field name:

  SqliteConfig.DatabaseFileName  long:"dbfile"        fallback: "databasefilename"
  PostgresConfig.MaxOpenConnections long:"maxconnections" fallback: "maxopenconnections"

In both cases the documented yaml key in sample-conf.yaml matches the
long: tag, not the fallback. So a user who follows the documentation
and sets sqlite.dbfile or postgres.maxconnections in their config file
has those values silently ignored. For sqlite, this causes Aperture to
resolve DatabaseFileName to the hardcoded defaultSqliteDatabasePath
(~/Library/Application Support/Aperture/aperture.db on macOS), a
directory that typically does not exist, and SQLite fails to open the
DB with "unable to open database file: out of memory (14)" (CANTOPEN).

Fix: add yaml: tags matching the existing long: tags so goccy/go-yaml
reads the documented keys. Also add yaml:"skipmigrations" to both
SkipMigrations fields for consistency.
@maml maml force-pushed the sqlite-yaml-tags branch from 239df90 to d3c96ed Compare April 18, 2026 18:55
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