api7 / api7/a7

config validate: detect bare/null unsupported sections (true key-presence)

Open
#33 1 comment 0 reactions 1 assignee View on GitHub

@shreemaan-abhishek is already working on this.

Since May 18, 2026.

Dominant language
Go
Stars
1
Forks
0
Avg merge
1h 3m
Merged PRs (30d)
1

Description

Part of #22. Follow-up to review feedback on #31.

Problem

The current cfg.<Section> != nil check in pkg/cmd/config/validate/validate.go and pkg/cmd/config/configutil/configutil.go only rejects explicitly-empty unsupported sections (e.g. upstreams: []). It does not reject:

  • upstreams: (bare key, no value) — unmarshals to nil
  • upstreams: null — unmarshals to nil

Same for consumer_groups and service_templates. A user who declares any of these forms gets silent acceptance.

Fix

Two-pass parse: first into map[string]yaml.Node (or map[string]json.RawMessage for JSON), check whether the key is present at all, then decode into the typed api.ConfigFile. If a key for an unsupported section is present, reject regardless of value.

Tests

Extend TestConfigValidate_EmptyUnsupportedSections (or add a sibling table) with cases:

  • upstreams: (no value)
  • upstreams: null
  • consumer_groups: / consumer_groups: null
  • service_templates: / service_templates: null

All should produce the same "X are not supported" error as the existing [] cases.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.