Skip to content

openspec config set workflows '[...]' fails — config set cannot set the array-typed workflows key #1216

@Draqun

Description

@Draqun

Hi.

Summary

There is no way to set the array-typed workflows config key via openspec config set. Any value is treated as a string and rejected by schema validation, so switching to the custom profile non-interactively is impossible — even though config set advertises "auto-coerce types" and workflows is a known top-level key.

Environment

  • OpenSpec CLI: 1.4.1 (latest from npm @fission-ai/openspec)
  • Node: >= 20
  • OS: Linux
  • Scenario: switching the global profile from core to custom to enable new / ff workflows

Steps to reproduce

openspec config set profile custom        # OK
openspec config set workflows '["new","ff","apply","archive"]'

Actual result

Error: Invalid configuration - workflows: Invalid input: expected array, received string

profile is now left as custom while workflows is unset, so getProfileWorkflows('custom', undefined) resolves to [] (zero workflows). If openspec update runs in this state, the project loses all /opsx:* commands and skills.

Expected result

The value should be parsed as an array and stored, configuring the custom profile non-interactively (e.g. workflows: ["new","ff","apply","archive"]).

Root cause

coerceValue (core/config-schema.js) only coerces boolean, number, or string:

export function coerceValue(value, forceString = false) {
    if (forceString) return value;
    if (value === 'true')  return true;
    if (value === 'false') return false;
    const num = Number(value);
    if (!isNaN(num) && isFinite(num) && value.trim() !== '') return num;
    return value; // arrays / JSON fall through as a raw string
}

workflows is declared as z.array(z.string()) in GlobalConfigSchema and is the only array-typed settable key. Because coerceValue never produces an array, config set workflows ... always fails Zod validation, despite workflows being present in KNOWN_TOP_LEVEL_KEYS and the command help reading "Set a value (auto-coerce types)".

Workarounds

  • Interactive picker: openspec config profile (no preset argument).
  • Hand-edit ~/.config/openspec/config.json and add the workflows array manually.

Suggested fix

  • JSON-parse values for array/object-typed keys in config set (e.g. attempt JSON.parse and fall back to the current string coercion), or
  • add an explicit --json flag / a repeatable --append <workflow> form for list keys, and/or
  • document that workflows cannot be set via config set and must go through the interactive openspec config profile picker.

Related

Best regards.
Draqun

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions