Skip to content

fix: resolve CLI bugs found during GA validation#31

Merged
shreemaan-abhishek merged 9 commits into
masterfrom
ga-readiness-validation-fixes
May 18, 2026
Merged

fix: resolve CLI bugs found during GA validation#31
shreemaan-abhishek merged 9 commits into
masterfrom
ga-readiness-validation-fixes

Conversation

@shreemaan-abhishek
Copy link
Copy Markdown
Contributor

@shreemaan-abhishek shreemaan-abhishek commented May 14, 2026

Summary

Bug fixes surfaced while validating the a7 CLI against a real API7 EE 3.9.12 instance (the GA test plan run, Phases B–C). Each fix ships with regression coverage. Also adds the GA test plan and the resulting test report under docs/.

Bug fixes

  • ssl — flag-based ssl update silently dropped partial updates; now requires --cert/--key.
  • plugin-metadataplugin-metadata get -o yaml emitted a byte array; now passes the decoded map to the exporter.
  • pluginplugin get -o yaml emitted JSON; now honors any --output value.
  • stream-routestream-route create had no --name flag; added the Name field and validation.
  • configconfig validate silently accepted an unsupported top-level service_templates section; now rejected on the validate and diff/sync paths.

Docs

  • docs/ga-test-plan.md — the GA readiness test plan (local API7 EE 3.9.12).
  • docs/ga-test-report.md — the report from running it: bug write-ups, observations, exit-criteria assessment.

Test plan

  • go build ./..., go vet ./..., go test ./... all pass locally.
  • Unit regression tests added/updated for ssl and stream-route.
  • E2E regression tests added: TestPluginMetadata_GetYAML, TestPlugin_GetYAML, TestStreamRoute_CreateRequiresName, TestConfigValidate* (run with -tags e2e against a live instance).

Part of #22. Relates to #25 and #26.

Summary by CodeRabbit

  • Bug Fixes

    • SSL update command now requires both certificate and key flags together
    • Plugin metadata and plugin YAML output formatting corrected
    • Stream-route create now requires a name field
  • New Features

    • Declarative config validation now rejects top-level unsupported sections (including explicit/empty upstreams, consumer_groups, and service_templates)
    • Plugin/get and plugin-metadata/get honor YAML output
  • Documentation

    • Added GA readiness test plan and execution report documenting phases, results, and bug handling
  • Tests

    • Added/expanded unit and e2e tests for config validation, SSL updates, plugin YAML output, and stream-route creation

Review Change Stack

Flag-based ssl update silently dropped partial updates. Require --cert/--key so updates do not lose fields.
Pass the decoded map to the exporter instead of json.RawMessage so -o yaml no longer renders a byte array.
plugin get -o yaml emitted JSON. Honor any --output value, not just json.
stream-route create had no --name flag. Add the Name field and validation.
config validate silently accepted a top-level service_templates section. Reject it on the validate and diff/sync paths.
Copilot AI review requested due to automatic review settings May 14, 2026 08:35
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 65e1c714-b74b-4260-b3bb-3ac1d3dcb2b5

📥 Commits

Reviewing files that changed from the base of the PR and between cf46aa8 and 1fbffa7.

📒 Files selected for processing (4)
  • docs/ga-test-plan.md
  • pkg/cmd/config/configutil/configutil.go
  • pkg/cmd/config/validate/validate.go
  • pkg/cmd/ssl/update/update_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • pkg/cmd/config/configutil/configutil.go
  • pkg/cmd/config/validate/validate.go

📝 Walkthrough

Walkthrough

Adds GA readiness plan and report docs; rejects top-level service_templates in declarative configs; requires --name for stream-route create; requires both --cert and --key for flag-based ssl updates; fixes plugin/plugin-metadata YAML output; and adds unit and E2E tests.

Changes

GA Readiness Testing & Bug Fixes

Layer / File(s) Summary
GA Test Plan and Execution Report
docs/ga-test-plan.md, docs/ga-test-report.md
Complete GA readiness plan (four phases), environment/pre-flight steps, execution report, results matrix, bug list (BUG-1..BUG-5), and explicit exit criteria.
Service Templates Rejection in Declarative Config
pkg/api/types_config.go, pkg/cmd/config/configutil/configutil.go, pkg/cmd/config/validate/validate.go, test/e2e/config_test.go, pkg/cmd/config/validate/validate_test.go
Adds ConfigFile.ServiceTemplates; validation now rejects top-level service_templates and treats explicitly-declared empty upstreams/consumer_groups as presence errors; includes unit and E2E tests.
Stream Route Name Field Requirement
pkg/api/types_stream_route.go, pkg/cmd/stream-route/create/create.go, pkg/cmd/stream-route/create/create_test.go, test/e2e/stream_route_test.go
Adds StreamRoute.Name; stream-route create exposes --name, enforces name in flag and file flows, decodes file-mode responses, and adds unit+E2E tests for missing-name and successful creates.
SSL Update Flag-Based Validation
pkg/cmd/ssl/update/update.go, pkg/cmd/ssl/update/update_test.go, test/e2e/ssl_test.go
ssl update now requires both --cert and --key for flag-based updates; unit tests updated/added and E2E test verifies error on missing flags and success when both provided.
Plugin & Plugin-Metadata YAML Output Format Fixes
pkg/cmd/plugin-metadata/get/get.go, pkg/cmd/plugin/get/get.go, test/e2e/plugin_metadata_test.go, test/e2e/plugin_test.go
plugin-metadata get exports decoded metadata for YAML; plugin get honors --output for non-JSON formats; E2E tests validate YAML serialization/unmarshalling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • api7/a7#21: Related changes to config validation rejecting unsupported top-level sections.
  • api7/a7#16: Overlaps on ssl update behavior and related tests.
  • api7/a7#6: Related E2E test adjustments around stream-route creation and readback.
🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: resolve CLI bugs found during GA validation' accurately summarizes the main changes in the PR: it documents bug fixes discovered during GA testing that resolve five CLI issues across ssl, plugin-metadata, plugin, stream-route, and config validate commands.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
E2e Test Quality Review ✅ Passed E2E tests are complete: real services, cleanup via t.Cleanup, clear assertions, proper error checking. All 5 bugs covered with regression tests. Unit tests validate edge cases. No unrelated code.
Security Check ✅ Passed Security review complete. No vulnerabilities found across all 7 categories: SSL keys properly redacted, no hardcoded secrets, no unencrypted storage, proper validation in place.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ga-readiness-validation-fixes

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
test/e2e/ssl_test.go (1)

176-181: ⚡ Quick win

Strengthen the failed-update assertion to prevent false positives.

After the rejected update, you assert old SNI exists, but not that the new SNI is absent. Adding that check makes the regression stricter.

Suggested test hardening
 	snis := requireJSONArray(t, ssl["snis"], "ssl.snis")
 	assert.Contains(t, snis, "require-cert.example.com")
+	assert.NotContains(t, snis, "require-cert-updated.example.com")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/e2e/ssl_test.go` around lines 176 - 181, The test currently checks that
the original SNI ("require-cert.example.com") remains after a rejected update
but doesn't assert the new (rejected) SNI is absent; update the assertion block
around the ssl lookup (using runA7JSON, requireJSONArray and the snis variable)
to also assert that the rejected/new SNI value is not present (e.g., add an
assert.NotContains(t, snis, "<new-sni-host>") after the existing
assert.Contains) so the test fails if the rejected update accidentally added the
new SNI.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/ga-test-plan.md`:
- Around line 26-30: The fenced code block containing the environment variables
(A7_ADMIN_URL, A7_TOKEN, A7_GATEWAY_GROUP) is missing a language tag which
triggers MD040; update the opening fence to include a language (e.g., "text") so
it becomes ```text to satisfy markdown linting while keeping the block content
unchanged.

In `@pkg/cmd/config/configutil/configutil.go`:
- Around line 245-247: The validator currently only rejects service_templates
when cfg.ServiceTemplates has items; change the check to also reject an
explicitly set empty section by testing for a non-nil slice instead of length.
Replace the condition using len(cfg.ServiceTemplates) with a check like
cfg.ServiceTemplates != nil (or cfg.ServiceTemplates != nil ||
len(cfg.ServiceTemplates) > 0) so that an explicit service_templates: [] is
treated as unsupported and appended to the unsupported list (referencing
cfg.ServiceTemplates and the unsupported variable in configutil.go).

In `@pkg/cmd/config/validate/validate.go`:
- Around line 106-108: The current check only rejects non-empty slices
(len(cfg.ServiceTemplates) > 0) and therefore allows an explicitly-present empty
section; change the condition to detect presence instead of length by checking
for nil (if cfg.ServiceTemplates != nil) and append the same error to errs.
Update the validate logic that references cfg.ServiceTemplates and errs in
validate.go so any explicitly-provided service_templates (including []) is
rejected.

In `@pkg/cmd/ssl/update/update_test.go`:
- Around line 90-92: The test currently serializes the SSL payload (body) into
the error using "%#v", which can expose cert/key material; update the assertion
in update_test.go so that when the check on body.Cert and body.Key fails you
return a non-sensitive error message (e.g., "unexpected cert/key in payload" or
include only boolean context), removing any serialization of body, Cert, or Key
values; ensure the failing message references only that the cert/key did not
match expected flags and does not print the payload contents.

---

Nitpick comments:
In `@test/e2e/ssl_test.go`:
- Around line 176-181: The test currently checks that the original SNI
("require-cert.example.com") remains after a rejected update but doesn't assert
the new (rejected) SNI is absent; update the assertion block around the ssl
lookup (using runA7JSON, requireJSONArray and the snis variable) to also assert
that the rejected/new SNI value is not present (e.g., add an
assert.NotContains(t, snis, "<new-sni-host>") after the existing
assert.Contains) so the test fails if the rejected update accidentally added the
new SNI.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 893f658c-30f9-424c-840f-6a38143ea3ea

📥 Commits

Reviewing files that changed from the base of the PR and between 7b67da5 and 1a6e0f7.

📒 Files selected for processing (17)
  • docs/ga-test-plan.md
  • docs/ga-test-report.md
  • pkg/api/types_config.go
  • pkg/api/types_stream_route.go
  • pkg/cmd/config/configutil/configutil.go
  • pkg/cmd/config/validate/validate.go
  • pkg/cmd/plugin-metadata/get/get.go
  • pkg/cmd/plugin/get/get.go
  • pkg/cmd/ssl/update/update.go
  • pkg/cmd/ssl/update/update_test.go
  • pkg/cmd/stream-route/create/create.go
  • pkg/cmd/stream-route/create/create_test.go
  • test/e2e/config_test.go
  • test/e2e/plugin_metadata_test.go
  • test/e2e/plugin_test.go
  • test/e2e/ssl_test.go
  • test/e2e/stream_route_test.go

Comment thread docs/ga-test-plan.md
Comment thread pkg/cmd/config/configutil/configutil.go Outdated
Comment thread pkg/cmd/config/validate/validate.go Outdated
Comment thread pkg/cmd/ssl/update/update_test.go
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses multiple correctness bugs discovered during GA validation of the a7 CLI against a real API7 EE 3.9.12 instance, and adds/updates regression coverage plus GA documentation.

Changes:

  • Fix output-format handling for plugin get and plugin-metadata get so -o yaml emits valid YAML objects (not JSON / byte arrays).
  • Fix runtime resource command validation/behavior: require --cert/--key for flag-based ssl update, add --name (and API field) for flag-based stream-route create.
  • Reject unsupported declarative service_templates sections in config validate and config diff/sync validation paths; add E2E + unit coverage and GA plan/report docs.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/e2e/stream_route_test.go Adds E2E regression tests for stream-route flag create requiring --name and successful flag create round-trip assertions.
test/e2e/ssl_test.go Adds E2E regression coverage ensuring flag-based ssl update requires cert/key and does not silently drop changes.
test/e2e/plugin_test.go Adds E2E regression coverage ensuring plugin get -o yaml produces valid YAML (not JSON).
test/e2e/plugin_metadata_test.go Adds E2E regression coverage ensuring plugin-metadata get -o yaml produces a YAML map.
test/e2e/config_test.go Adds E2E coverage that config validate rejects unsupported service_templates.
pkg/cmd/stream-route/create/create.go Adds --name flag and enforces name for both file-based and flag-based stream-route creation; includes Name in request payload.
pkg/cmd/stream-route/create/create_test.go Updates/extends unit tests for required name validation in both flag and -f paths.
pkg/cmd/ssl/update/update.go Prevents flag-based partial ssl update by requiring both --cert and --key.
pkg/cmd/ssl/update/update_test.go Updates unit tests to reflect API7 EE GET behavior (no cert/key) and adds regression test for requiring cert/key.
pkg/cmd/plugin/get/get.go Ensures explicit --output is honored via exporter (yaml/json) instead of falling back to JSON.
pkg/cmd/plugin-metadata/get/get.go Exports decoded metadata map (not json.RawMessage) so YAML output is correct.
pkg/cmd/config/validate/validate.go Adds explicit validation error when service_templates is present in declarative config.
pkg/cmd/config/configutil/configutil.go Extends supported-section validation so diff/sync paths reject service_templates.
pkg/api/types_stream_route.go Adds name field to StreamRoute type to match API7 EE requirements.
pkg/api/types_config.go Adds ServiceTemplates field to detect/reject unsupported declarative section instead of silently dropping it.
docs/ga-test-plan.md Adds GA validation test plan for local API7 EE 3.9.12.
docs/ga-test-report.md Adds GA test report capturing findings, regressions, and exit-criteria assessment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/cmd/stream-route/create/create.go
Comment thread test/e2e/stream_route_test.go Outdated
- stream-route create: decode response before passing to the exporter so -o yaml renders a YAML map, not a byte sequence
- config validate / configutil: reject explicit empty unsupported sections (upstreams, consumer_groups, service_templates) via != nil check; declaring an unsupported section is itself an error
- ssl update test: drop %#v of the SSL body from the mock-mismatch error message
- ssl e2e: also assert the rejected SNI is absent after a failed update
- stream-route e2e helper: use upstreamNodeHost/Port helpers for consistency
- new e2e: TestStreamRoute_CreateFromFileYAML guards the json.RawMessage regression on the file-based create path
- new unit test: TestConfigValidate_EmptyUnsupportedSections covers the three empty-section cases
Copilot AI review requested due to automatic review settings May 18, 2026 06:52
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.

Comment thread pkg/cmd/config/validate/validate.go Outdated
Comment thread pkg/cmd/config/configutil/configutil.go Outdated
Comment thread docs/ga-test-plan.md
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/cmd/ssl/update/update_test.go`:
- Around line 121-123: The failing assertions leak cert/key material by printing
the full test output using "%+v"; replace those fatal messages to avoid
serializing secrets (e.g., remove "%+v" usage and only assert silently or log
safe fields). Specifically, update the assertions that reference the test
variable "output" (and comparisons against "api.RedactedSSLKey") so they call
t.Fatalf with a non-sensitive message like "expected ssl key to be redacted in
output" (or include only the redacted value), and apply the same fix to the
other occurrences around the test checks noted (the blocks that compare
output.Key/output.Cert to api.RedactedSSLKey) so no cert/key bytes are ever
formatted into the error string.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 35b3bd8b-c89c-43c7-85fd-e4f75768a5a0

📥 Commits

Reviewing files that changed from the base of the PR and between 1a6e0f7 and cf46aa8.

📒 Files selected for processing (7)
  • pkg/cmd/config/configutil/configutil.go
  • pkg/cmd/config/validate/validate.go
  • pkg/cmd/config/validate/validate_test.go
  • pkg/cmd/ssl/update/update_test.go
  • pkg/cmd/stream-route/create/create.go
  • test/e2e/ssl_test.go
  • test/e2e/stream_route_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • pkg/cmd/config/validate/validate.go
  • pkg/cmd/stream-route/create/create.go
  • test/e2e/stream_route_test.go

Comment thread pkg/cmd/ssl/update/update_test.go
- ssl update_test: drop %+v output / %#v payload from the remaining three failure messages
- config validate / configutil: correct the comment to match what != nil actually catches (explicitly-empty sections); bare 'upstreams:' / 'upstreams: null' still slip through and need a separate key-presence pass tracked as a follow-up
- docs/ga-test-plan: replace hardcoded contributor path with <path-to-a7-repo>
@shreemaan-abhishek shreemaan-abhishek merged commit a3e5222 into master May 18, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants