Skip to content

docs: share field descriptions with benthos and scan benthos internals for copies - #4877

Merged
JakeSCahill merged 9 commits into
mainfrom
docs/share-benthos-fields
Oct 9, 2026
Merged

JakeSCahill merged 9 commits into
mainfrom
docs/share-benthos-fields

Conversation

@JakeSCahill

@JakeSCahill JakeSCahill commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #4876. Don't merge until redpanda-data/benthos#513 is released: this uses the field constructors that PR adds, so it doesn't build against benthos v4.81.0. Before merging, bump benthos.

Why

#4875 fails CI on copied field descriptions but skips copies of benthos's internal packages, because this repo can't import them. Those were real copies: internal/oauth2 and internal/retries forked the benthos field definitions, so a fix on one side never reached the other.

What changes

  • Built with benthos constructors:
    • OAuth2 fields use service.NewOAuth2Field: the otlp outputs, the redpanda tracer, and schema registry. The duplicate oauth2.FieldSpec is deleted; parsing is unchanged because the field names are identical.
    • Retry fields use service.NewRetryBackOffFields: the kinesis, firehose, sqs, dynamodb, and mongodb outputs and processor. The duplicate retries.CommonRetryBackOffFields is deleted.
    • Kafka's max_retries uses service.NewMaxRetriesField.
  • Made specific, where the behavior differs from the benthos text it copied:
    • gateway rate_limit and sync_response.*: the gateway rejects with 429 and Retry-After.
    • file output path: validates file names.
    • redis rate limit count: a shared counter under key.
    • otlp_http follow_redirects: a non-2xx response fails the write.
    • cassandra reconnection, max_retries, and backoff: gocql semantics.
    • pulsar tls.root_cas_file.
    • cypher basic_auth username and password.
    • bigquery max_in_flight.
  • Wider copy test:
    • scans benthos internal/ as well as public/
    • names fields built with unqualified constructors
    • reads docs.FieldString("name", "description") style constructors

Schema diff for the touched components, before and after, with benthos on #513: no field names, types, defaults, or flags change. OAuth2 scopes and endpoint_params now show their versions (3.45.0 and 4.21.0), and some descriptions change as listed above.

With a local replace on #513, the build passes, the copy test reports zero copies, and tests and lint for the touched packages pass. As a negative control, restoring the old Pulsar text makes the copy test fail.

@JakeSCahill
JakeSCahill marked this pull request as ready for review September 27, 2026 18:06
service.NewStringField(hsiFieldRateLimit).
Description("An optional xref:components:rate_limits/about.adoc[rate limit] to throttle requests by.").
ShortDescription("An optional rate limit resource to throttle requests by.").
Description("The name of an optional xref:components:rate_limits/about.adoc[rate limit resource] that the gateway applies to each request it receives. When the rate limit is reached, the gateway rejects the request with a `429` response and a `Retry-After` header.").

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Generated docs aren't regenerated. This PR changes field descriptions in gateway, file, otlp_http, redis rate limit, cassandra, pulsar, oauth2 and retries. It doesn't update docs/modules/. For example, docs/modules/components/partials/fields/inputs/gateway.adoc still has the old "Specify the status code to return with synchronous responses" text.

CONTRIBUTING.md §6: "Run task docs and commit the result … CI fails on stale docs." CLAUDE.md says to regenerate with CGO_ENABLED=1 TAGS=x_benthos_extra task docs.

Suggested fix: regenerate the docs once benthos is bumped and commit the output in its own commit (§3.4.1).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This waits on the benthos release. The PR uses constructors and constants that are on benthos main but not yet released, so it can't build against the pinned v4.81.0. The docs regenerate in the same commit as the benthos bump.

Comment thread internal/retries/retries.go Resolved
Comment thread internal/retries/retries.go Resolved
Comment thread cmd/tools/docs_gen/copies_test.go Resolved
@JakeSCahill
JakeSCahill force-pushed the docs/share-benthos-fields branch from 8872cb1 to dfee1b5 Compare September 30, 2026 11:57
Comment on lines 165 to +176
service.NewStringField(hsiFieldRateLimit).
Description("An optional xref:components:rate_limits/about.adoc[rate limit] to throttle requests by.").
ShortDescription("An optional rate limit resource to throttle requests by.").
Description("The name of an optional xref:components:rate_limits/about.adoc[rate limit resource] that the gateway applies to each request it receives. When the rate limit is reached, the gateway rejects the request with a `429` response and a `Retry-After` header.").
ShortDescription("An optional rate limit resource that the gateway applies to each request.").
Default(""),
service.NewObjectField(hsiFieldResponse,
service.NewInterpolatedStringField(hsiFieldResponseStatus).
Description("Specify the status code to return with synchronous responses. This is a string value, which allows you to customize it based on resulting payloads and their metadata.").
ShortDescription("The status code returned with synchronous responses.").
Description("The HTTP status code that the gateway returns when the pipeline produces a synchronous response. The value is interpolated against the first response message, so the code can depend on its contents and metadata.").
ShortDescription("The HTTP status code the gateway returns with synchronous responses.").
Examples(`${! json("status") }`, `${! meta("status") }`).
Default("200"),
service.NewInterpolatedStringMapField(hsiFieldResponseHeaders).
Description("Specify headers to return with synchronous responses.").
Description("The headers that the gateway adds to synchronous responses. Header values are interpolated against the first response message.").

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Generated docs not regenerated (CONTRIBUTING.md §6). §6 says: "Run task docs and commit the result … CI fails on stale docs." This PR rewrites field descriptions here and in cassandra, cypher, bigquery, file, otlp_http, pulsar, redis rate_limit and others, but no files under docs/modules/ changed. For example, docs/modules/components/partials/fields/inputs/gateway.adoc still has the old text "Specify headers to return with synchronous responses".

Fix: after the benthos bump that adds the new constructors, regenerate with CGO_ENABLED=1 TAGS=x_benthos_extra task docs (see CLAUDE.md) and commit the updated partials.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This waits on the benthos release. The PR uses constructors and constants that are on benthos main but not yet released, so it can't build against the pinned v4.81.0. The docs regenerate in the same commit as the benthos bump.

Comment thread cmd/tools/docs_gen/copies_test.go Resolved
@JakeSCahill
JakeSCahill force-pushed the docs/share-benthos-fields branch from dfee1b5 to 9e47c83 Compare October 1, 2026 15:42
Comment thread internal/oauth2/oauth2.go

// ParseConfig parses OAuth2 configuration from a parsed config.
// ParseConfig parses OAuth2 configuration from a parsed config of a field
// defined with service.NewOAuth2Field.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Build dependency: go.mod still pins benthos v4.81.0

This PR switches to service.NewOAuth2Field, service.NewRetryBackOffFields and service.NewMaxRetriesField and deletes the local copies (oauth2.FieldSpec, retries.CommonRetryBackOffFields, retries.MaxRetriesDescription). But go.mod was not changed, so it still pins github.com/redpanda-data/benthos/v4 v4.81.0. The first commit's message says: "Needs a benthos release that exports the new constants." If v4.81.0 doesn't export these constructors, every caller fails to compile (otlp, schemaregistry, redpanda tracer, aws, mongodb, kafka sarama).

Fix: bump benthos in go.mod/go.sum (task bump-benthos) in this PR, or hold the PR until that release exists.

Also check that the field names the new constructors produce still match what the parsers read. oauth2.ParseConfig reads fieldEnabled, fieldClientKey, etc. retries.CommonRetryBackOffCtorFromParsed reads max_retries, backoff.initial_interval, etc. The kafka sarama output parses with oskFieldMaxRetries. If any name differs, configs will fail to parse at runtime, not at compile time.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Expected. This PR waits on a benthos release that includes the new constructors. It gets the go.mod bump and regenerated docs then.

Comment thread cmd/tools/docs_gen/copies_test.go Resolved
@JakeSCahill
JakeSCahill force-pushed the docs/share-benthos-fields branch 2 times, most recently from d8113b5 to c31d0ac Compare October 5, 2026 14:43
@JakeSCahill
JakeSCahill force-pushed the docs/share-benthos-fields branch from c31d0ac to ff7b04a Compare October 5, 2026 16:12
@JakeSCahill
JakeSCahill force-pushed the docs/share-benthos-fields branch 2 times, most recently from fa3ee71 to 44dc6fa Compare October 7, 2026 14:44
@JakeSCahill
JakeSCahill force-pushed the docs/share-benthos-fields branch 2 times, most recently from 666ac2b to bf7d829 Compare October 8, 2026 14:34
@JakeSCahill
JakeSCahill removed this pull request from stack #4883 October 8, 2026 15:14
@Leward
Leward added this pull request to stack #4940 October 8, 2026 17:28
@JakeSCahill
JakeSCahill force-pushed the docs/share-benthos-fields branch from bf7d829 to 6f79099 Compare October 8, 2026 18:11
Base automatically changed from docs/required-versions to main October 8, 2026 18:11
…rnals

Use the retry and oauth2 description constants that benthos now exports
from public/service, and give the gateway, file, redis rate limit, otlp
http, and cassandra reconnection fields descriptions of their own
behaviour. The copies test now scans benthos's internal packages too.

Needs a benthos release that exports the new constants.
Use service.NewOAuth2Field, service.NewRetryBackOffFields and service.NewMaxRetriesField in place of the local copies, and give the pulsar root_cas_file field its own description of how the client uses the file.
@JakeSCahill
JakeSCahill force-pushed the docs/share-benthos-fields branch from 6f79099 to 39aa44e Compare October 8, 2026 18:11
@Leward
Leward self-requested a review October 8, 2026 18:24

@Leward Leward 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.

See inline comments

Comment thread internal/impl/cassandra/shared.go Outdated
LintRule(`root = if this.parse_duration().catch(0) < 1 { "reconnection.max_interval must be a positive duration"}`),
).
Description("Configure exponential backoff for reconnection attempts to DOWN nodes. When enabled, this replaces the driver's default constant reconnection policy with an exponential backoff strategy that gradually increases the delay between reconnection attempts. This reduces connection storm scenarios during widespread outages while ensuring eventual recovery.").Version("4.66.0").
Description("Exponential backoff for the retries the driver makes within one connection attempt to a host. It applies on the initial connection and on each `reconnect_interval` attempt to a node marked as DOWN, and replaces the driver's default of 3 retries 1s apart.").Version("4.66.0").

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.

gocql uses MaxRetries as the total number of connection attempts, not as the number of retries after the first attempt.
Each loop iteration is one connection attempt, and the loop runs GetMaxRetries() times: connectionpool.go#L565-L581 (gocql v1.7.0, the version in go.mod).
Thus the fallback ConstantReconnectionPolicy{MaxRetries: 3, Interval: 1 * time.Second} makes 3 attempts, not 3 retries.

Suggested change
Description("Exponential backoff for the retries the driver makes within one connection attempt to a host. It applies on the initial connection and on each `reconnect_interval` attempt to a node marked as DOWN, and replaces the driver's default of 3 retries 1s apart.").Version("4.66.0").
Description("Exponential backoff between the connection attempts that the driver makes each time it connects to a host. It applies on the initial connection and on each `reconnect_interval` attempt to a node marked as DOWN, and replaces the driver's default of 3 attempts 1s apart.").Version("4.66.0").

Lines 125 and 128 also say "the retries ... within one connection attempt". If you take this change, "the connection attempts each time the driver connects to a host" fits there too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, taken in 5339e84, and lines 125 and 128 now say "the connection attempts each time the driver connects to a host" too.

Comment thread internal/impl/cassandra/shared.go Outdated
@@ -122,13 +122,13 @@ func clientFields(tlsVersion string) []*service.ConfigField {
Description("The maximum number of retry attempts.").

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.

This PR does not change this text, but the PR body lists max_retries as changed.
The value is the total number of connection attempts: connectionpool.go#L565.
Also, the driver waits one more interval after the last failed attempt, before it returns the error: connectionpool.go#L581.

Suggested change
Description("The maximum number of retry attempts.").
Description("The maximum number of connection attempts each time the driver connects to a host.").

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Taken in 5339e84.

Comment thread internal/impl/io/output_file.go Outdated
Fields(
service.NewInterpolatedStringField(foFieldPath).
Description("The file to write to, if the file does not yet exist it will be created.").
Description("The path of the file to write to. The output creates the file and any missing parent directories. A write fails when the file name contains a NUL byte. On Windows it also fails for `<`, `>`, `:`, `\"`, `|`, `?`, `*`, and control characters, and on macOS for `:`, which macOS would turn into a path separator.").

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.

Two points:

  1. The code rejects a NUL byte anywhere in the path, not only in the file name: output_file.go#L268. The Windows and macOS checks look only at the file name: output_file.go#L275-L282.
  2. macOS does not turn : into a path separator. I ran os.WriteFile("a:b.txt", ...) on macOS 26.6 with APFS, and it created a:b.txt in the same directory. Finder shows : as /, but the file does not move. The claim comes from the code comment at L265-L266 and the error at L326, which have the same problem. The validation is still useful, so I suggest removing only the reason.
Suggested change
Description("The path of the file to write to. The output creates the file and any missing parent directories. A write fails when the file name contains a NUL byte. On Windows it also fails for `<`, `>`, `:`, `\"`, `|`, `?`, `*`, and control characters, and on macOS for `:`, which macOS would turn into a path separator.").
Description("The path of the file to write to. The output creates the file and any missing parent directories. A write fails when the path contains a NUL byte. On Windows it also fails when the file name contains `<`, `>`, `:`, `\"`, `|`, `?`, `*`, or a control character, and on macOS when the file name contains `:`.").

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for testing it. Taken in 5339e84. I also removed the HFS+/APFS reason from the code comment and from the error message, which now says the output rejects a colon on macOS.

Comment thread internal/impl/redis/rate_limit.go Outdated

spec.Field(service.NewIntField("count").
Description("The maximum number of messages to allow for a given period of time.").
Description("The maximum number of requests allowed in each `interval`. Requests are counted in Redis under `key`, so every Redpanda Connect instance that uses the same key shares this limit. The value must be greater than zero.").

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.

The counter is one key in one Redis instance: rate_limit.go#L101-L104. Instances share the limit only when they use the same Redis instance and the same key.

Suggested change
Description("The maximum number of requests allowed in each `interval`. Requests are counted in Redis under `key`, so every Redpanda Connect instance that uses the same key shares this limit. The value must be greater than zero.").
Description("The maximum number of requests allowed in each `interval`. Requests are counted in Redis under `key`, so every Redpanda Connect instance that uses the same Redis instance and the same `key` shares this limit. The value must be greater than zero.").

Not in this diff: the summary and description at L30-L31 call this a token bucket. The script is a fixed window counter: INCR, then PEXPIRE with interval on the first request of each window.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Taken in 5339e84. I also replaced "token bucket" in the summary and description with how it works: a fixed window that starts with its first request, shared by instances that use the same Redis instance and key.

Comment thread internal/impl/cypher/output.go Outdated
Comment on lines +50 to +52
Description("The graph database user to authenticate as, with `password` and, optionally, `realm`."),
service.NewStringField(coFieldBasicAuthPassword).
Description("The password to use for authentication. Used together with `username` for basic authentication.").
Description("The password of the graph database user set in `username`.").

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.

I suggest that these descriptions do not say what kind of server the user belongs to.

  • The engine is limited by the protocol, not by the Cypher language. The output connects with neo4j-go-driver (L22), and the uri examples use only neo4j:// and bolt:// schemes (L94-L103). So any server that speaks Bolt can be the target, for example Neo4j or Memgraph.
  • username is the user that the driver sends in neo4j.BasicAuth(user, pass, realm) (L84) when it connects to uri. It is an account on that server, whatever the engine is. "The graph database user" makes an assumption that the code does not need.
  • The new text must be different enough from other username fields to pass the copy test. Naming the driver and uri does that, and makes no claim about the engine. I did not run the copy test on this text.
Suggested change
Description("The graph database user to authenticate as, with `password` and, optionally, `realm`."),
service.NewStringField(coFieldBasicAuthPassword).
Description("The password to use for authentication. Used together with `username` for basic authentication.").
Description("The password of the graph database user set in `username`.").
Description("The user that the driver authenticates as when it connects to `uri`, with `password` and, optionally, `realm`."),
service.NewStringField(coFieldBasicAuthPassword).
Description("The password of the user set in `username`.").

Not in this diff: "graph database" is also at L46, L59, L89-L90, and L106. You can keep this change limited to these two fields, or fix all of them in a follow-up so the component stays consistent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Taken in 5339e84, and I fixed the other "graph database" mentions in the same change so the component reads consistently: the summary and description now say any database that speaks the Bolt protocol, such as Neo4j or Memgraph. The copies test passes on the new text.

…nd cypher auth text

- cassandra: max_retries counts connection attempts, not retries.
- file: the NUL check covers the whole path, and macOS doesn't turn ':'
  into a path separator (the code comment and error said so too).
- redis rate limit: a fixed window shared per Redis instance and key, not
  a token bucket.
- cypher: any Bolt server, not a particular graph database.
@JakeSCahill
JakeSCahill requested a review from Leward October 8, 2026 18:43
@JakeSCahill
JakeSCahill merged commit 307d925 into main Oct 9, 2026
11 checks passed
@JakeSCahill
JakeSCahill deleted the docs/share-benthos-fields branch October 9, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants