fix: config validation and agent name normalization (#531, #532, #533) #534

Merged
xiaonuo merged 1 commits from fix/531-532-533 into main 2026-05-26 06:09:56 +00:00
Owner

What

Fixes three configuration-related issues in cli-workflow:

  1. #531: config list now correctly masks apiKey field (was checking for apiKeyEnv)
  2. #532: config set now validates key paths and rejects unknown keys
  3. #533: uwf setup --agent uwf-hermes now produces correct agent command (no duplicate prefix)

Why

  • #531: After refactoring, the field name changed from apiKeyEnv to apiKey, but the masking logic wasn't updated
  • #532: Users could set arbitrary config keys without validation, leading to invalid configurations
  • #533: Agent name normalization was applied twice, resulting in double uwf- prefix

Changes

#531: apiKey masking

  • Updated maskApiKeys() in config.ts to check for apiKey instead of apiKeyEnv
  • Updated corresponding test fixtures

#532: config key validation

  • Added VALID_CONFIG_KEYS schema defining known keys and nested fields
  • Added validateConfigKey() function with comprehensive validation:
    • Rejects unknown top-level keys
    • Rejects unknown nested fields in providers/models/agents
    • Rejects incomplete nested paths
    • Rejects nested paths on scalar keys
  • Integrated validation into cmdConfigSet()
  • Added 11 new validation tests

#533: agent name normalization

  • Updated mergeConfig() in setup.ts to normalize agent names using existing _agentNameFromBinary() function
  • Now correctly strips uwf- prefix before constructing config entry
  • Added 2 new normalization tests

Test Results

All 306 tests passed
TypeScript compilation passed
Biome lint passed
No regressions

Ref

Fixes #531
Fixes #532
Fixes #533

## What Fixes three configuration-related issues in `cli-workflow`: 1. **#531**: `config list` now correctly masks `apiKey` field (was checking for `apiKeyEnv`) 2. **#532**: `config set` now validates key paths and rejects unknown keys 3. **#533**: `uwf setup --agent uwf-hermes` now produces correct agent command (no duplicate prefix) ## Why - #531: After refactoring, the field name changed from `apiKeyEnv` to `apiKey`, but the masking logic wasn't updated - #532: Users could set arbitrary config keys without validation, leading to invalid configurations - #533: Agent name normalization was applied twice, resulting in double `uwf-` prefix ## Changes ### #531: apiKey masking - Updated `maskApiKeys()` in `config.ts` to check for `apiKey` instead of `apiKeyEnv` - Updated corresponding test fixtures ### #532: config key validation - Added `VALID_CONFIG_KEYS` schema defining known keys and nested fields - Added `validateConfigKey()` function with comprehensive validation: - Rejects unknown top-level keys - Rejects unknown nested fields in providers/models/agents - Rejects incomplete nested paths - Rejects nested paths on scalar keys - Integrated validation into `cmdConfigSet()` - Added 11 new validation tests ### #533: agent name normalization - Updated `mergeConfig()` in `setup.ts` to normalize agent names using existing `_agentNameFromBinary()` function - Now correctly strips `uwf-` prefix before constructing config entry - Added 2 new normalization tests ## Test Results ✅ All 306 tests passed ✅ TypeScript compilation passed ✅ Biome lint passed ✅ No regressions ## Ref Fixes #531 Fixes #532 Fixes #533
xiaoju added 1 commit 2026-05-26 06:05:55 +00:00
This commit addresses three related issues in the CLI config and setup commands:

1. Issue #531: Fix config list apiKey masking
   - maskApiKeys() now checks for 'apiKey' instead of 'apiKeyEnv'
   - Updated tests to use apiKey field throughout

2. Issue #532: Add config set key validation
   - Reject unknown top-level keys with helpful error messages
   - Reject unknown nested fields in providers/models/agents
   - Reject incomplete paths and nested paths on scalar keys
   - Added VALID_CONFIG_KEYS schema and validateConfigKey() function

3. Issue #533: Fix agent name double-prefix in setup
   - mergeConfig() now uses _agentNameFromBinary() to normalize agent names
   - 'uwf-hermes' input now produces 'hermes' key with 'uwf-hermes' command
   - Added tests for prefixed agent names

All tests passing, no regressions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
xiaonuo merged commit e43d4f3bbf into main 2026-05-26 06:09:56 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#534