Skip to content

Enable env-backed config writeback and bootstrap missing config file#171

Merged
CJackHwang merged 5 commits intodevfrom
codex/fix-issue-#170-in-ds2api
Mar 30, 2026
Merged

Enable env-backed config writeback and bootstrap missing config file#171
CJackHwang merged 5 commits intodevfrom
codex/fix-issue-#170-in-ds2api

Conversation

@CJackHwang
Copy link
Copy Markdown
Owner

Motivation

  • Allow configurations provided via the DS2API_CONFIG_JSON env var to be persisted to disk when desired and to bootstrap a missing config file so runtime changes are not lost, while still preserving special-case behavior for Vercel.

Description

  • Add envWritebackEnabled() to recognize DS2API_ENV_WRITEBACK truthy values and update imports to include fmt and path/filepath.
  • Change loadConfig() to, when DS2API_CONFIG_JSON is present and writeback is enabled (and not Vercel), prefer an existing file-backed config if present and attempt to write a bootstrap file when the config path does not exist.
  • Allow Store.Save() and store.saveLocked() to persist an env-backed store when writeback is enabled by calling writeConfigBytes() and clear s.fromEnv after a successful write, while retaining the previous skip behavior for Vercel or when writeback is disabled.
  • Add helpers writeConfigFile() and writeConfigBytes() to marshal configs, create parent directories with os.MkdirAll, and write files safely.
  • Add unit test TestEnvBackedStoreWritebackBootstrapsMissingConfigFile to verify bootstrapping from env JSON and subsequent persistence and reload semantics.

Testing

  • Ran the package unit tests for the config package with go test ./internal/config -run TestEnvBackedStore*, which executed the new TestEnvBackedStoreWritebackBootstrapsMissingConfigFile and related tests, and they passed.
  • Ran wider checks with go test ./... to ensure no regressions in other packages, and all tests passed.

Codex Task

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ds2api Ready Ready Preview, Comment Mar 30, 2026 3:40pm

Copy link
Copy Markdown

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

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: f3555ae9b0

ℹ️ 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".

@CJackHwang CJackHwang merged commit efebe9e into dev Mar 30, 2026
3 checks passed
@CJackHwang CJackHwang deleted the codex/fix-issue-#170-in-ds2api branch March 30, 2026 16:01
CJackHwang added a commit that referenced this pull request Mar 30, 2026
Merge pull request #171 from CJackHwang/codex/fix-issue-#170-in-ds2api

Enable env-backed config writeback and bootstrap missing config file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accounts added via Admin UI are lost on container restart when using DS2API_CONFIG_JSON env

1 participant