Skip to content

Move all configuration value validity checks into one place

Currently, functions like getAiAssistedCodeSuggestionsConfiguration get configuration values without validating them. That means, despite what the type system says about them, they may have the wrong shape.

Rather than passing around these technically unknown values and checking their shape in various places, getAiAssistedCodeSuggestionsConfiguration (and similar) should return validated data structures.

One possibility would be to implement something like a ValidatedWorkspaceConfiguration class that receives a mapping of configuration leaf nodes to type predicates. It could have a getValueOrDefault method that, given a leaf configuration identifier string, would:

  1. Get the raw configuration value
  2. Check it with the type predicate
  3. If true, return value
  4. If false, get the configuration default
  5. Check it with the type predicate
  6. If true, return default
  7. Throw error

Tasks

Edited by Mark Florian