Skip to content

fix(config): keep '=' inside the value of config set - #411

Open
JspIIV wants to merge 1 commit into
genlayerlabs:v0.40-devfrom
JspIIV:fix/config-set-preserves-equals-in-value
Open

fix(config): keep '=' inside the value of config set#411
JspIIV wants to merge 1 commit into
genlayerlabs:v0.40-devfrom
JspIIV:fix/config-set-preserves-equals-in-value

Conversation

@JspIIV

@JspIIV JspIIV commented Aug 22, 2026

Copy link
Copy Markdown

Problem

config set destructures the split, so it only ever keeps the first two parts:

const [key, value] = keyValue.split("=");

A value containing = is silently truncated at the first one. Two everyday cases:

genlayer config set apiKey=YWJjZGVm==
  stored: YWJjZGVm                          # base64 padding dropped

genlayer config set rpcUrl=https://rpc.example.com/v1?key=abc&mode=fast
  stored: https://rpc.example.com/v1?key    # query string cut off

There is no error and no warning. The command reports Configuration successfully updated, and the value only turns out to be wrong later, when whatever reads it fails for a reason that does not point back here.

Change

Splits on the first separator instead:

const separatorIndex = keyValue.indexOf("=");
const key = separatorIndex === -1 ? "" : keyValue.slice(0, separatorIndex);
const value = separatorIndex === -1 ? undefined : keyValue.slice(separatorIndex + 1);

The two existing behaviours are unchanged:

  • no separator at all (config set invalidFormat) still fails with Invalid format. Use 'key=value'.
  • an empty value (config set defaultNetwork=) still stores ""

Tests

Three cases added to tests/actions/getSetReset.test.ts: base64 padding, a query string, and the empty value. The first two fail on v0.40-dev and pass with the change; the empty-value and invalid-format tests pass either way, which is what pins the unchanged behaviour.

Verification

Run against v0.40-dev at e822a9e:

npx vitest run                          72 files, 799 tests, all passing
npx vitest run tests/actions/getSetReset.test.ts   10 passing

And with the fix reverted, to confirm the new tests actually catch it:

× set method keeps '=' inside the value
  → expected "writeConfig" to be called with arguments: [ 'apiKey', 'YWJjZGVm==' ]
× set method keeps a query string intact
  → expected "writeConfig" to be called with arguments: [ 'rpcUrl', …(1) ]

Branch

Targeting v0.40-dev as the active integration branch per docs/BRANCHING.md. Happy to retarget at a stable branch if you would rather ship it directly.

One thing I left alone

reset() has a delete config[key] that operates on a local copy and is never written back — the removal actually happens because writeConfig(key, undefined) makes JSON.stringify drop the key. It works, so I did not touch it here, but removeConfig(key) already exists and says it directly. Happy to send that separately if it is worth having.

keyValue.split("=") destructures only the first two parts, so a value
containing "=" was silently truncated at the first one. base64 padding
and URLs with a query string are the common cases:

  config set apiKey=YWJjZGVm==                 stored YWJjZGVm
  config set rpcUrl=https://x/v1?key=a&m=fast  stored https://x/v1?key

Splits on the first separator instead. An empty value and a missing
separator behave as before.
@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

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

Review profile: CHILL

Plan: Pro Plus

Run ID: 2f1f2e65-9b1a-46f1-86db-95f456722b3b

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

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.

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