antonmedv/fx · error

Unexpected state: %v

Error message

Unexpected state: %v

What it means

Default-branch guard in Tokenizer.scanStream: the tokenizer state machine reached a state value it does not recognize. This can only happen if the internal state variable is corrupted or a new state was added without a corresponding case, so it signals an implementation bug rather than bad user input.

Source

Thrown at internal/shlex/shlex.go:385

						if nextRune == '\n' {
							state = startState
							token := &Token{
								tokenType: tokenType,
								value:     string(value)}
							return token, err
						} else {
							value = append(value, nextRune)
						}
					}
				default:
					{
						value = append(value, nextRune)
					}
				}
			}
		default:
			{
				return nil, fmt.Errorf("Unexpected state: %v", state)
			}
		}
	}
}

// Next returns the next token in the stream.
func (t *Tokenizer) Next() (*Token, error) {
	return t.scanStream()
}

// Split partitions a string into a slice of strings.
func Split(s string) ([]string, error) {
	l := NewLexer(strings.NewReader(s))
	subStrings := make([]string, 0)
	for {
		word, err := l.Next()
		if err != nil {
			if err == io.EOF {

View on GitHub (pinned to 4f31cd3a0c)

Solutions

  1. Add a case for the reported state in scanStream
  2. Report as a bug with the input that triggered it
  3. Retry with simpler, well-formed quoted input as a workaround
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at internal/shlex/shlex.go:385 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of antonmedv/fx@4f31cd3a0c (2026-09-02). Data as JSON: /api/errors/ac1c632b0d5c043c. Report an issue: GitHub.