Skip to content

feat(core): align schema and backend health check config - #557

Merged
bzp2010 merged 5 commits into
mainfrom
bzp/feat-healthcheck-http-related
Aug 5, 2026
Merged

feat(core): align schema and backend health check config#557
bzp2010 merged 5 commits into
mainfrom
bzp/feat-healthcheck-http-related

Conversation

@bzp2010

@bzp2010 bzp2010 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Description

ADC uses a rigid schema definition that doesn’t align well with the APISIX schema, and since the backend passes these through without conversion, some fields are incorrectly configured in the backend.

This PR aligns with the new fields in the APISIX health checker, such as http_req_body and http_method; it also updates the transformers on the backend so that field names are correctly converted to the names required by the backend.

The #541 implemented a fix, but it only covers req_headers and does not include other new configuration items; moreover, it takes the approach of having the ADC adapt to the APISIX schema, which is not ideal.

The ADC determines its own schema and will never be forced to modify the schema due to external changes. The schema it defines is converted to the various backends on a best-effort basis.
We consider transform errors to be bugs, but schema inconsistencies are not.

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible

Note: upstream.checks.active.http_request_headers => upstream.checks.active.http_req_headers, since it never worked before anyway, it's no big problem.

Summary by CodeRabbit

  • New Features

    • Added configurable HTTP methods, request headers, and request bodies for active upstream health checks.
    • Added support for the PURGE HTTP method where applicable.
    • Standardized health-check field names across API7, APISIX, and ADC integrations.
  • Bug Fixes

    • Preserved health-check settings during configuration import and export.
    • Ensured passive checks and undefined health checks continue to behave correctly.

@bzp2010
bzp2010 requested a review from juzhiyuan August 5, 2026 03:26
@bzp2010 bzp2010 self-assigned this Aug 5, 2026
@bzp2010 bzp2010 added test/api7 Trigger the API7 test on the PR test/apisix-standalone Trigger the APISIX standalone test on the PR labels Aug 5, 2026
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change updates health-check schemas and backend types, adds explicit bidirectional header mappings for API7 and APISIX, and adds transformation coverage. It also updates selected package and workspace dependency versions.

Changes

Health-check mapping

Layer / File(s) Summary
Health-check contracts
libs/sdk/src/core/schema.ts, schema.json, libs/backend-api7/src/typing.ts, libs/backend-apisix/src/typing.ts, libs/backend-apisix-standalone/src/typing.ts
Health-check definitions now support http_method, http_req_headers, and http_req_body. Backend types expose req_headers where required.
Backend health-check transformations
libs/backend-api7/src/transformer.ts, libs/backend-apisix/src/transformer.ts, libs/backend-apisix-standalone/src/transformer.ts, libs/backend-apisix-standalone/src/operator.ts, libs/backend-api7/test/*, libs/backend-apisix/test/*, libs/backend-apisix-standalone/test/*
Transformations map req_headers and http_req_headers in both directions. They preserve other active and passive health-check fields. Tests cover mappings, request bodies, and inline service upstreams.

Tooling updates

Layer / File(s) Summary
Dependency version updates
libs/converter-openapi/package.json, package.json, pnpm-workspace.yaml
OpenAPI dependencies, pnpm, and workspace dependency overrides were updated.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • api7/adc#541: Modifies the same health-check header names in schemas and typing.
  • api7/adc#550: Modifies related APISIX health-check transformer logic.

Suggested reviewers: juzhiyuan

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
E2e Test Quality Review ⚠️ Warning The PR adds only direct transformer/operator unit tests; git diff shows no E2E changes, and existing E2E health-check coverage does not assert the new fields. Add E2E sync-and-dump tests against real backend services for http_method, http_req_headers, http_req_body, passive checks, defaults, and invalid or boundary inputs.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes to the core schema and backend health-check configuration.
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.
Security Check ✅ Passed PR changes only health-check schemas and field mappings; no new logging, persistence, endpoints, ownership checks, TLS inversion, shared-resource logic, or secret-resolution paths were found.
✨ 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 bzp/feat-healthcheck-http-related

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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 `@libs/backend-api7/src/transformer.ts`:
- Around line 261-280: Update FromADC.transformService to pass inline
service.upstream through this.transformUpstream instead of casting it directly,
ensuring active check fields such as http_req_headers map to req_headers
consistently. Add a service-level regression test covering an inline upstream
with active check request headers and verify the transformed API7 output.

In `@libs/backend-apisix-standalone/src/operator.ts`:
- Around line 483-504: Validate the `opts.server` URL in the operator
initialization or `sync()` path before constructing or sending `newConfig` to
`${server}${ENDPOINT_CONFIG}`. Reject any server URL whose protocol is not
HTTPS, and do not send the configuration when validation fails; leave redirect
behavior unchanged.
🪄 Autofix

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: 822bc74e-12b0-4ced-bca7-da10cf4af402

📥 Commits

Reviewing files that changed from the base of the PR and between f56359f and b39c22b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (16)
  • libs/backend-api7/src/transformer.ts
  • libs/backend-api7/src/typing.ts
  • libs/backend-api7/test/transformer.spec.ts
  • libs/backend-apisix-standalone/src/operator.ts
  • libs/backend-apisix-standalone/src/transformer.ts
  • libs/backend-apisix-standalone/src/typing.ts
  • libs/backend-apisix-standalone/test/operator.spec.ts
  • libs/backend-apisix-standalone/test/transformer.spec.ts
  • libs/backend-apisix/src/transformer.ts
  • libs/backend-apisix/src/typing.ts
  • libs/backend-apisix/test/transformer.spec.ts
  • libs/converter-openapi/package.json
  • libs/sdk/src/core/schema.ts
  • package.json
  • pnpm-workspace.yaml
  • schema.json

Comment thread libs/backend-api7/src/transformer.ts
Comment thread libs/backend-apisix-standalone/src/operator.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
libs/backend-api7/test/transformer.spec.ts (1)

90-104: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use a meaningful result variable.

Rename out to transformedService. The current name does not identify the value under test.

As per coding guidelines, test variable names must be meaningful.

Proposed change
-      const out = new FromADC().transformService({
+      const transformedService = new FromADC().transformService({
...
-      expect(out.upstream?.checks).toEqual({
+      expect(transformedService.upstream?.checks).toEqual({
🤖 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 `@libs/backend-api7/test/transformer.spec.ts` around lines 90 - 104, Rename the
result variable `out` in the `FromADC().transformService` test to
`transformedService`, and update the subsequent `expect` reference to use the
new meaningful name.

Source: Coding guidelines

🤖 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.

Nitpick comments:
In `@libs/backend-api7/test/transformer.spec.ts`:
- Around line 90-104: Rename the result variable `out` in the
`FromADC().transformService` test to `transformedService`, and update the
subsequent `expect` reference to use the new meaningful name.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e3691550-b8be-47bb-8c88-3031b72aa38f

📥 Commits

Reviewing files that changed from the base of the PR and between b39c22b and dd75a61.

📒 Files selected for processing (2)
  • libs/backend-api7/src/transformer.ts
  • libs/backend-api7/test/transformer.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • libs/backend-api7/src/transformer.ts

@bzp2010
bzp2010 merged commit f7f7246 into main Aug 5, 2026
43 checks passed
@bzp2010
bzp2010 deleted the bzp/feat-healthcheck-http-related branch August 5, 2026 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test/api7 Trigger the API7 test on the PR test/apisix-standalone Trigger the APISIX standalone test on the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants