Skip to content

api/v2: support TOML output for changefeed query via content negotiation#5357

Open
JesseZhuang wants to merge 1 commit into
pingcap:masterfrom
JesseZhuang:jessezhuang/changefeed-query-toml-api
Open

api/v2: support TOML output for changefeed query via content negotiation#5357
JesseZhuang wants to merge 1 commit into
pingcap:masterfrom
JesseZhuang:jessezhuang/changefeed-query-toml-api

Conversation

@JesseZhuang

@JesseZhuang JesseZhuang commented Jun 11, 2026

Copy link
Copy Markdown

What problem does this PR solve?

cdc cli changefeed create --config consumes TOML, but the changefeed query API and CLI only return JSON. This asymmetry makes changefeed migration, config review, and version control more manual than necessary.

Per the design discussion in #4936, the feature is implemented at the API layer (content negotiation) rather than as a CLI-only conversion. This PR is the foundation for that.

Issue Number: ref #4936

What is changed and how it works?

Add Accept: application/toml content negotiation to the single changefeed GET endpoint (GET /api/v2/changefeeds/:changefeed_id). With no Accept header or Accept: application/json, the response is JSON exactly as before; with Accept: application/toml, the same data is returned as TOML.

curl -H 'Accept: application/toml' '{host}/api/v2/changefeeds/{id}?keyspace={ks}'

How it works:

  1. TOML struct tags on the API model. Added kebab-case toml tags across the ReplicaConfig tree and the top-level ChangeFeedInfo fields, matching the internal config.ReplicaConfig tags that changefeed create --config parses, so the output round-trips back into create.
  2. Human-readable durations/timestamps. Added MarshalText/UnmarshalText to JSONDuration (api/v2) and JSONTime (pkg/api) so TOML renders durations as 10m0s and timestamps as 2006-01-02 15:04:05.000 instead of empty tables/raw nanoseconds. JSON output is unchanged — JSONDuration still marshals to nanoseconds in JSON.
  3. Content negotiation helper. A small respondWithFormat helper reads the Accept header and emits TOML via c.Data(...) or falls back to c.JSON(...). Only GetChangeFeed uses it; LIST and all other endpoints are unchanged.
  4. GID is omitted from TOML (toml:"-"): its uint64 low/high can exceed TOML's signed int64 range so the encoded value would not parse back, and it is internal runtime metadata, not part of a creatable config. It is still present in the JSON response (unchanged).
  5. Two pre-existing JSON tag fixes on SinkConfig (agreed in cdc cli: support TOML output and migration-optimized diff for changefeed query #4936): advance_timeoutadvance_timeout_in_sec, send-all-bootstrap-at-startsend_all_bootstrap_at_start.

This is PR 1 of 3 for #4936. PR 2 will add the ?view=config query parameter (diff-against-defaults, stripping runtime fields). PR 3 will add the CLI --format and --view flags.

Check List

Tests

  • Added/modified unit tests

New unit tests cover: JSONDuration/JSONTime text round-trips; encoding the full default config to TOML and decoding it back into the internal config.ReplicaConfig with zero undecoded keys (guards all ~200 tags against drift); and Accept header content negotiation (default/json/toml/toml-with-charset).

Integration tests

Added changefeed_query_toml_api (wired into tests/integration_tests/run_light_it_in_ci.sh), run locally on macOS against a real cluster — all sub-tests passing:

  • default response and Accept: application/json both return JSON
  • Accept: application/toml returns a TOML body with kebab-case top-level keys; gid omitted
  • TOML uses kebab-case keys (never snake_case) and groups config under [config] / [config.*]
  • durations render as readable strings (not empty tables); JSONTime fields render as readable timestamps
  • overrides applied in both JSON and TOML; JSON↔TOML field correspondence holds
  • sink URI credentials are redacted in both formats
  • the exported TOML config re-imports successfully via changefeed create --config

Questions

Will it cause performance regression or break compatibility?

No performance impact. The default (JSON) response path is unchanged. The two SinkConfig JSON tag renames change the field names in API responses (advance_timeoutadvance_timeout_in_sec, send-all-bootstrap-at-startsend_all_bootstrap_at_start) — please confirm these are acceptable.

Do you need to update user documentation, design documentation or monitoring documentation?

User documentation for TOML output will be added once the CLI flags land in PR 3.

Notes for reviewer

  • The full TOML view currently includes runtime fields (state, error, checkpoint-time); stripping them is handled by ?view=config in PR 2.
  • GID is omitted from TOML (toml:"-"): its uint64 low/high can exceed TOML's signed int64 range, so the encoded value would not parse back, and it is internal runtime metadata rather than part of a creatable config. It remains present in the JSON response (unchanged).

Release note

Support returning a changefeed as TOML from the GET changefeed API via the `Accept: application/toml` header.

Summary by CodeRabbit

  • New Features

    • Added TOML response support and content negotiation for v2 changefeed queries (via Accept: application/toml, including parameterized headers).
    • TOML output now uses kebab-case field names and renders durations/timestamps in a human-readable text form, omitting runtime-only metadata.
  • Bug Fixes

    • Ensured v2 changefeed responses consistently use the new format negotiation helper while preserving the 200 payload.
  • Tests

    • Added unit and integration coverage for TOML/JSON compatibility, key mapping, redaction, round-trip parsing, and default vs TOML response behavior.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds TOML text serialization for API time/duration types, adds TOML struct tags across changefeed config models, implements Accept-based content negotiation via respondWithFormat, switches GetChangeFeed to use it, and provides unit and integration tests validating TOML output and import round-trip.

Changes

Changefeed TOML API Support

Layer / File(s) Summary
Text serialization for duration and time types
api/v2/model.go, pkg/api/util.go
JSONDuration and JSONTime implement MarshalText/UnmarshalText to serialize as human-readable strings in TOML and other text encoders, while retaining JSON nanosecond/timestamp behavior via existing MarshalJSON/UnmarshalJSON.
TOML struct tags across configuration models
api/v2/model.go
ReplicaConfig, SinkConfig, FilterConfig, ChangeFeedInfo, ConsistentConfig, ChangefeedSchedulerConfig, codec/sink protocol configs, and related structs receive toml: tags for kebab-case field mapping; GID excluded via toml:"-"; some JSON keys renamed for consistency.
HTTP content negotiation and handler wiring
api/v2/helper.go, api/v2/changefeed.go
Adds wantsTOML helper to detect Accept: application/toml and respondWithFormat to emit TOML (with charset) or JSON. GetChangeFeed now calls respondWithFormat instead of direct c.JSON.
Unit tests for TOML serialization and negotiation
api/v2/changefeed_toml_test.go
Tests cover JSONDuration text round-trip and error cases, TOML encoding shape for ReplicaConfig and ChangeFeedInfo, default-config round-trip decoding, and respondWithFormat content negotiation with various Accept headers.
Integration test with TOML validation and round-trip
tests/integration_tests/changefeed_query_toml_api/run.sh, tests/integration_tests/changefeed_query_toml_api/conf/overrides.toml, tests/integration_tests/run_light_it_in_ci.sh
Bash script creates multiple changefeeds, fetches JSON and TOML outputs, asserts format/key naming/credential redaction/override application, validates human-readable duration/timestamp rendering in TOML, and verifies exported TOML [config] can be reimported to create equivalent changefeed; registered in light CI suite.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • flowbehappy
  • asddongmen
  • lidezhu

Poem

🐰 I hopped through tags and headers bright,
To make configs read like daylight,
Durations sing, timestamps glow—
TOML answers when clients show,
A nibble, a hop—API made light ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 61.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely describes the main change: adding TOML output support to the changefeed query API via content negotiation, which is the primary objective.
Description check ✅ Passed The PR description is comprehensive and well-structured, covering the problem statement, implementation approach, test coverage (unit and integration), performance/compatibility considerations, and release notes.
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.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@ti-chi-bot ti-chi-bot Bot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jun 11, 2026

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces API-layer TOML support for v2 changefeed endpoints, enabling content negotiation via the Accept header to return changefeed configurations in TOML format. It adds toml tags to the configuration models, implements text marshaling/unmarshaling for custom duration and time types to ensure human-readable outputs, and includes comprehensive tests. The feedback suggests making the Accept header check case-insensitive to align with RFC standards, and updating RegionCountRefreshInterval to use *JSONDuration instead of *time.Duration so that it serializes as a human-readable string in TOML.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread api/v2/helper.go
Comment thread api/v2/model.go
@ti-chi-bot ti-chi-bot Bot added contribution This PR is from a community contributor. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Jun 11, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

Hi @JesseZhuang. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jun 11, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 `@api/v2/helper.go`:
- Around line 111-122: The TOML branch in respondWithFormat currently calls
c.Error and returns on toml.NewEncoder(...).Encode failure, leaving no HTTP
response; update respondWithFormat so that when toml encoding fails (inside the
wantsTOML branch) it both attaches the error and writes an appropriate HTTP
error response (e.g., use c.AbortWithStatusJSON or c.String/c.Data with status
500 and a brief error message) before returning; ensure you reference
respondWithFormat and the toml encoder error path so the client always receives
a status code and body on failure.
🪄 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: 30502969-440d-4d3d-bdab-5a144bda95f1

📥 Commits

Reviewing files that changed from the base of the PR and between 998336f and cc5a6da.

📒 Files selected for processing (8)
  • api/v2/changefeed.go
  • api/v2/changefeed_toml_test.go
  • api/v2/helper.go
  • api/v2/model.go
  • pkg/api/util.go
  • tests/integration_tests/changefeed_query_toml_api/conf/overrides.toml
  • tests/integration_tests/changefeed_query_toml_api/run.sh
  • tests/integration_tests/run_light_it_in_ci.sh

Comment thread api/v2/helper.go
@JesseZhuang JesseZhuang force-pushed the jessezhuang/changefeed-query-toml-api branch from cc5a6da to 2d10447 Compare June 11, 2026 19:38

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
api/v2/helper.go (1)

112-123: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

TOML encoding error still leaves client with no HTTP response.

The past review comment remains valid: when toml.Encode fails at Line 115, the function calls c.Error and returns without writing a response body or status code. Gin's c.Error only attaches the error to the context—it doesn't send an HTTP response. The client receives an incomplete HTTP response (no status, no body).

You must write an HTTP error response before returning.

🔧 Proposed fix
 func respondWithFormat(c *gin.Context, code int, obj any) {
 	if wantsTOML(c) {
 		var buf bytes.Buffer
 		if err := toml.NewEncoder(&buf).Encode(obj); err != nil {
 			_ = c.Error(errors.Trace(err))
+			c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to encode TOML"})
 			return
 		}
 		c.Data(code, mimeTOML+"; charset=utf-8", buf.Bytes())
 		return
 	}
 	c.JSON(code, obj)
 }
🤖 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 `@api/v2/helper.go` around lines 112 - 123, respondWithFormat currently calls
c.Error on toml encoding failure inside the wantsTOML branch and returns without
writing a real HTTP response; update that branch so when
toml.NewEncoder(&buf).Encode(obj) returns an error you both attach the error to
the context and send an HTTP error response (e.g., use c.String or c.JSON with
an appropriate 500 status and a short error message or the error.Error()) before
returning; modify the error handling around toml.NewEncoder/Encode in
respondWithFormat so the client always receives a status and body even on
encoding failures, keeping wantsTOML, toml.NewEncoder, c.Error and c.Data usage
intact elsewhere.
🧹 Nitpick comments (1)
tests/integration_tests/changefeed_query_toml_api/run.sh (1)

14-14: 💤 Low value

Quote variables to prevent word splitting and globbing.

Shellcheck flags unquoted variables at Lines 14, 71, 73, 74, and 299. While test environments typically use safe paths, quoting is best practice to prevent unexpected failures if paths contain spaces or glob characters.

📝 Proposed fixes
-source $CUR/../_utils/test_prepare
+source "$CUR/../_utils/test_prepare"
-	rm -rf $WORK_DIR && mkdir -p $WORK_DIR
+	rm -rf "$WORK_DIR" && mkdir -p "$WORK_DIR"
-	start_tidb_cluster --workdir $WORK_DIR
-	run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY
+	start_tidb_cluster --workdir "$WORK_DIR"
+	run_cdc_server --workdir "$WORK_DIR" --binary "$CDC_BINARY"
-check_logs $WORK_DIR
+check_logs "$WORK_DIR"

Also applies to: 71-71, 73-74, 299-299

🤖 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 `@tests/integration_tests/changefeed_query_toml_api/run.sh` at line 14, The
shell script uses unquoted variable expansions (notably CUR) when sourcing or
using paths which can cause word-splitting/globbing; update occurrences like
source $CUR/../_utils/test_prepare and other uses at the same file (lines
referenced) to wrap variable expansions in double quotes (e.g., source
"$CUR/../_utils/test_prepare" and similarly quote "$CUR", "$BIN_DIR", or other
variables used at lines 71, 73, 74, 299) so all path variables are quoted
consistently to prevent splitting/globbing.
🤖 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.

Duplicate comments:
In `@api/v2/helper.go`:
- Around line 112-123: respondWithFormat currently calls c.Error on toml
encoding failure inside the wantsTOML branch and returns without writing a real
HTTP response; update that branch so when toml.NewEncoder(&buf).Encode(obj)
returns an error you both attach the error to the context and send an HTTP error
response (e.g., use c.String or c.JSON with an appropriate 500 status and a
short error message or the error.Error()) before returning; modify the error
handling around toml.NewEncoder/Encode in respondWithFormat so the client always
receives a status and body even on encoding failures, keeping wantsTOML,
toml.NewEncoder, c.Error and c.Data usage intact elsewhere.

---

Nitpick comments:
In `@tests/integration_tests/changefeed_query_toml_api/run.sh`:
- Line 14: The shell script uses unquoted variable expansions (notably CUR) when
sourcing or using paths which can cause word-splitting/globbing; update
occurrences like source $CUR/../_utils/test_prepare and other uses at the same
file (lines referenced) to wrap variable expansions in double quotes (e.g.,
source "$CUR/../_utils/test_prepare" and similarly quote "$CUR", "$BIN_DIR", or
other variables used at lines 71, 73, 74, 299) so all path variables are quoted
consistently to prevent splitting/globbing.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9ebfdd24-e206-4b8c-97e3-4c2771cc7cff

📥 Commits

Reviewing files that changed from the base of the PR and between cc5a6da and 2d10447.

📒 Files selected for processing (8)
  • api/v2/changefeed.go
  • api/v2/changefeed_toml_test.go
  • api/v2/helper.go
  • api/v2/model.go
  • pkg/api/util.go
  • tests/integration_tests/changefeed_query_toml_api/conf/overrides.toml
  • tests/integration_tests/changefeed_query_toml_api/run.sh
  • tests/integration_tests/run_light_it_in_ci.sh
✅ Files skipped from review due to trivial changes (1)
  • tests/integration_tests/run_light_it_in_ci.sh
🚧 Files skipped from review as they are similar to previous changes (5)
  • api/v2/changefeed.go
  • tests/integration_tests/changefeed_query_toml_api/conf/overrides.toml
  • pkg/api/util.go
  • api/v2/changefeed_toml_test.go
  • api/v2/model.go

Add API-layer TOML support for the GET single changefeed endpoint, the
foundation for issue pingcap#4936 (changefeed query as TOML / clean config export).

- Add kebab-case `toml` struct tags across the api/v2 ReplicaConfig tree and
  the ChangeFeedInfo top-level fields, matching the internal config.ReplicaConfig
  tags that `changefeed create --config` parses, so the output round-trips.
- Add MarshalText/UnmarshalText to JSONDuration (api/v2) and JSONTime (pkg/api)
  so durations and timestamps serialize as human-readable strings under TOML
  instead of empty tables; JSON output is unchanged (still nanoseconds).
- Omit the runtime-only GID field from TOML (toml:"-").
- Add a respondWithFormat helper that negotiates on the Accept header:
  application/toml returns TOML, otherwise JSON (the unchanged default).
- Fix two pre-existing JSON tag inconsistencies on SinkConfig:
  advance_timeout -> advance_timeout_in_sec, send-all-bootstrap-at-start ->
  send_all_bootstrap_at_start.

Unit tests cover duration/time round-trips, full-default-config round-trip into
the internal config (guards all tags against drift), and Accept negotiation. A
new integration test (changefeed_query_toml_api) exercises the HTTP endpoint and
re-imports the exported TOML via `changefeed create --config`.

Issue Number: ref pingcap#4936

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@JesseZhuang JesseZhuang force-pushed the jessezhuang/changefeed-query-toml-api branch from 2d10447 to 6dcca2a Compare June 22, 2026 18:27

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 `@api/v2/changefeed_toml_test.go`:
- Around line 166-169: The test in ChangeFeedInfo contains a t.Parallel() call
that enables parallel execution, but the gin.SetMode() call on the subsequent
line mutates global process state which can cause race conditions and test
flakiness. Remove the t.Parallel() call from the beginning of this test since it
is incompatible with the global state mutation caused by
gin.SetMode(gin.TestMode).

In `@tests/integration_tests/changefeed_query_toml_api/run.sh`:
- Line 14: Quote all unquoted variable expansions to prevent breaking on
whitespace or globbing in workspace paths. In the run.sh file, add double quotes
around variable expansions at lines 14 (the $CUR variable in the source
command), lines 71, 73-74, and line 299. For example, change `source
$CUR/../_utils/test_prepare` to `source "$CUR"/../_utils/test_prepare` to ensure
the path is treated as a single argument even if it contains spaces or special
characters.
🪄 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: 3b4097b5-aef6-4946-807e-945f03543c99

📥 Commits

Reviewing files that changed from the base of the PR and between 2d10447 and 6dcca2a.

📒 Files selected for processing (8)
  • api/v2/changefeed.go
  • api/v2/changefeed_toml_test.go
  • api/v2/helper.go
  • api/v2/model.go
  • pkg/api/util.go
  • tests/integration_tests/changefeed_query_toml_api/conf/overrides.toml
  • tests/integration_tests/changefeed_query_toml_api/run.sh
  • tests/integration_tests/run_light_it_in_ci.sh
✅ Files skipped from review due to trivial changes (1)
  • tests/integration_tests/changefeed_query_toml_api/conf/overrides.toml
🚧 Files skipped from review as they are similar to previous changes (5)
  • api/v2/changefeed.go
  • pkg/api/util.go
  • api/v2/helper.go
  • tests/integration_tests/run_light_it_in_ci.sh
  • api/v2/model.go

Comment on lines +166 to +169
t.Parallel()

gin.SetMode(gin.TestMode)
obj := &ChangeFeedInfo{ID: "cf-1", SinkURI: "blackhole://"}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Avoid parallelizing a test that mutates Gin global state.

Line 166 runs in parallel while Line 168 calls gin.SetMode(...), which mutates global process state and can make sibling tests flaky.

As per coding guidelines, "Prefer focused deterministic tests; see docs/agents/testing.md before adding or changing tests."

Suggested fix
 func TestRespondWithFormat(t *testing.T) {
-	t.Parallel()
-
 	gin.SetMode(gin.TestMode)
 	obj := &ChangeFeedInfo{ID: "cf-1", SinkURI: "blackhole://"}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
t.Parallel()
gin.SetMode(gin.TestMode)
obj := &ChangeFeedInfo{ID: "cf-1", SinkURI: "blackhole://"}
func TestRespondWithFormat(t *testing.T) {
gin.SetMode(gin.TestMode)
obj := &ChangeFeedInfo{ID: "cf-1", SinkURI: "blackhole://"}
🤖 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 `@api/v2/changefeed_toml_test.go` around lines 166 - 169, The test in
ChangeFeedInfo contains a t.Parallel() call that enables parallel execution, but
the gin.SetMode() call on the subsequent line mutates global process state which
can cause race conditions and test flakiness. Remove the t.Parallel() call from
the beginning of this test since it is incompatible with the global state
mutation caused by gin.SetMode(gin.TestMode).

Source: Coding guidelines

set -euo pipefail

CUR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
source $CUR/../_utils/test_prepare

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Quote path/binary variables used as arguments.

Line 14, Line 71, Line 73, Line 74, and Line 299 use unquoted expansions; this can break on whitespace/globbing in workspace paths.

Suggested fix
-source $CUR/../_utils/test_prepare
+source "$CUR/../_utils/test_prepare"
@@
-	rm -rf $WORK_DIR && mkdir -p $WORK_DIR
+	rm -rf "$WORK_DIR" && mkdir -p "$WORK_DIR"
@@
-	start_tidb_cluster --workdir $WORK_DIR
-	run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY
+	start_tidb_cluster --workdir "$WORK_DIR"
+	run_cdc_server --workdir "$WORK_DIR" --binary "$CDC_BINARY"
@@
-check_logs $WORK_DIR
+check_logs "$WORK_DIR"

Also applies to: 71-71, 73-74, 299-299

🧰 Tools
🪛 Shellcheck (0.11.0)

[info] 14-14: Not following: ./../_utils/test_prepare was not specified as input (see shellcheck -x).

(SC1091)


[info] 14-14: Double quote to prevent globbing and word splitting.

(SC2086)

🤖 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 `@tests/integration_tests/changefeed_query_toml_api/run.sh` at line 14, Quote
all unquoted variable expansions to prevent breaking on whitespace or globbing
in workspace paths. In the run.sh file, add double quotes around variable
expansions at lines 14 (the $CUR variable in the source command), lines 71,
73-74, and line 299. For example, change `source $CUR/../_utils/test_prepare` to
`source "$CUR"/../_utils/test_prepare` to ensure the path is treated as a single
argument even if it contains spaces or special characters.

Source: Linters/SAST tools

@lidezhu lidezhu added the ok-to-test Indicates a PR is ready to be tested. label Jun 22, 2026
@lidezhu

lidezhu commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

/test all

@lidezhu lidezhu requested a review from wk989898 June 23, 2026 17:07
@ti-chi-bot

ti-chi-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lidezhu, wk989898

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 24, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-06-24 02:45:56.859643556 +0000 UTC m=+88440.522869070: ☑️ agreed by wk989898.

@ti-chi-bot ti-chi-bot Bot added the approved label Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved contribution This PR is from a community contributor. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. needs-1-more-lgtm Indicates a PR needs 1 more LGTM. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. ok-to-test Indicates a PR is ready to be tested. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants