Possible bug in `configlet lint`

Relating to this topic in discord, after changing .status.test_runner to true, configlet lint fails with

$ bin/configlet lint
The lint command is under development.
To check your track using the latest linting rules,
please regularly update configlet and re-run this command.

The `test_runner` key is missing:
/Users/glennj/src/exercism/tracks/euphoria/config.json

Configlet detected at least one problem.
For more information on resolving the problems, please see the documentation:
https://exercism.org/docs/building/configlet/lint

The key is clearly not missing.

Tracing through configlet, we have this in src/lint/track_config.nim

proc hasValidStatus(data: JsonNode; path: Path): bool =
  const k = "status"
  if hasObject(data, k, path):
    let d = data[k]
    let checks = [
      hasBoolean(d, "concept_exercises", path, k),
      hasBoolean(d, "test_runner", path, k),
      hasBoolean(d, "representer", path, k),
      hasBoolean(d, "analyzer", path, k),
    ]
    result = allTrue(checks)

Then in src/lint/validators.nim

proc hasBoolean*(data: JsonNode; key: string; path: Path; context = "";
                 isRequired = true; errorAnnotation = ""): bool =
  if data.hasKey(key, path, context, isRequired):
    result = isBoolean(data[key], key, path, context, isRequired,
                       errorAnnotation = errorAnnotation)
  elif not isRequired:
    result = true

and

proc hasKey(data: JsonNode; key: string; path: Path; context: string;
            isRequired: bool; errorAnnotation = ""): bool =
  ## Returns true if `data` contains the key `key`. Otherwise, returns false
  ## and, if `isRequired` is true, prints an error message.
  if data.hasKey(key):
    result = true
  elif isRequired:
    result.setFalseAndPrint(&"The {format(context, key)} key is missing", path,
                             annotation = errorAnnotation)

Somehow

  if data.hasKey(key):

fails when test_runner is set to true.

I’m not seeing the same failure for any other key in .status

Looks like a tricky issue, @ErikSchierboom @ee7-1282

Have you set .test_runner.average_run_time, too? Because configlet doesn’t fail to lint the PHP track config.json, which has .status.test_runner set to true also.

1 Like

No, it’s not set. Thanks!