Skip to content

feat: server-side tolerance for unknown --info tokens (upstream parity)#4055

Merged
oferchen merged 6 commits into
masterfrom
feat/info-server-side-unknown-token-tolerance-2168
May 14, 2026
Merged

feat: server-side tolerance for unknown --info tokens (upstream parity)#4055
oferchen merged 6 commits into
masterfrom
feat/info-server-side-unknown-token-tolerance-2168

Conversation

@oferchen
Copy link
Copy Markdown
Owner

Summary

Make oc-rsync's --info= parser tolerate unknown tokens when running on the server side, matching upstream rsync's parse_output_words() (options.c:465). The client-side parser keeps erroring on unknown tokens so typos still surface at the source.

This preserves cross-version compatibility: a newer client can forward info names this build has not learned yet without breaking the transfer.

Upstream reference

// rsync-3.4.1/options.c:465-469 - parse_output_words()
if (len && !words[j].name && !am_server) {
    rprintf(FERROR, "Unknown %s item: \"%.*s\"\n",
        words[j].help, len, str);
    exit_cleanup(RERR_SYNTAX);
}

The !am_server clause is the entire mechanism: known tokens still apply on either side, but the Unknown ... exit only fires on the client.

Changes

  • parse_info_flags_server() is a new entry point that calls the shared parser with am_server=true; InfoFlagSettings::apply_with_mode() skips the unknown-token error in that mode while still rejecting malformed inputs (empty tokens, out-of-range levels for known names).
  • Server-mode argument parsing now recognises --info=FLAGS, captures the raw values, and validates them via parse_info_flags_server. Before this change the argument leaked into the positional path list because is_known_server_long_flag did not know about it.

Test plan

  • parse_info_flags_client_rejects_unknown_token - client mode still errors with Unknown --info item ...
  • parse_info_flags_server_accepts_unknown_token - server mode silently accepts an unknown token
  • parse_info_flags_server_mixes_known_and_unknown - known tokens still apply in server mode when unknown ones are interleaved
  • long_flags_info_is_captured - server-mode argument parser captures --info=FLAGS instead of dropping it into positional args

Refs #2168

Mirror upstream's parse_output_words() guard so the server side
silently skips unknown info-flag names. A newer client can forward
info tokens this build has not learned yet without breaking the
transfer, while the client-side parser still rejects unknown tokens
so typos surface at the source.

upstream: options.c parse_output_words - the `!am_server` check at
options.c:465 short-circuits the `Unknown --info item` exit.

Refs #2168
@github-actions github-actions Bot added the enhancement New feature or request label May 14, 2026
oferchen added 5 commits May 14, 2026 12:48
The apply() helper is only invoked from unit tests now that production
code routes through apply_with_mode(). Clippy's dead-code lint flagged
it under -D warnings. Gating it with #[cfg(test)] keeps tests compiling
while satisfying the lib build.
clippy::err_expect lint became active after deriving Debug on
InfoFlagSettings; the lint requires the success type to implement
Debug to suggest the simpler expect_err form.
@oferchen oferchen merged commit a12f666 into master May 14, 2026
39 checks passed
@oferchen oferchen deleted the feat/info-server-side-unknown-token-tolerance-2168 branch May 14, 2026 14:57
oferchen added a commit that referenced this pull request May 18, 2026
…y) (#4055)

* feat: server-side tolerance for unknown --info tokens

Mirror upstream's parse_output_words() guard so the server side
silently skips unknown info-flag names. A newer client can forward
info tokens this build has not learned yet without breaking the
transfer, while the client-side parser still rejects unknown tokens
so typos surface at the source.

upstream: options.c parse_output_words - the `!am_server` check at
options.c:465 short-circuits the `Unknown --info item` exit.

Refs #2168

* fix: gate unused apply() wrapper behind cfg(test)

The apply() helper is only invoked from unit tests now that production
code routes through apply_with_mode(). Clippy's dead-code lint flagged
it under -D warnings. Gating it with #[cfg(test)] keeps tests compiling
while satisfying the lib build.

* fix: derive Debug on InfoFlagSettings for expect_err in tests

* fix: replace err().expect() with expect_err() in test sites

clippy::err_expect lint became active after deriving Debug on
InfoFlagSettings; the lint requires the success type to implement
Debug to suggest the simpler expect_err form.

* fix: derive Debug on DebugFlagSettings for expect_err in tests

* fix: convert remaining multi-line err().expect() to expect_err()
oferchen added a commit that referenced this pull request May 18, 2026
…y) (#4055)

* feat: server-side tolerance for unknown --info tokens

Mirror upstream's parse_output_words() guard so the server side
silently skips unknown info-flag names. A newer client can forward
info tokens this build has not learned yet without breaking the
transfer, while the client-side parser still rejects unknown tokens
so typos surface at the source.

upstream: options.c parse_output_words - the `!am_server` check at
options.c:465 short-circuits the `Unknown --info item` exit.

Refs #2168

* fix: gate unused apply() wrapper behind cfg(test)

The apply() helper is only invoked from unit tests now that production
code routes through apply_with_mode(). Clippy's dead-code lint flagged
it under -D warnings. Gating it with #[cfg(test)] keeps tests compiling
while satisfying the lib build.

* fix: derive Debug on InfoFlagSettings for expect_err in tests

* fix: replace err().expect() with expect_err() in test sites

clippy::err_expect lint became active after deriving Debug on
InfoFlagSettings; the lint requires the success type to implement
Debug to suggest the simpler expect_err form.

* fix: derive Debug on DebugFlagSettings for expect_err in tests

* fix: convert remaining multi-line err().expect() to expect_err()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant