Skip to content

fix(plugins): avoid exposing compilation result internals - #10363

Open
agisilaos wants to merge 2 commits into
swiftlang:mainfrom
agisilaos:fix/plugin-build-diagnostics-8091
Open

fix(plugins): avoid exposing compilation result internals#10363
agisilaos wants to merge 2 commits into
swiftlang:mainfrom
agisilaos:fix/plugin-build-diagnostics-8091

Conversation

@agisilaos

Copy link
Copy Markdown
Contributor

Fixes #8091

Summary

Avoid exposing the internal PluginCompilationResult representation when plugin compilation fails.

SwiftPM currently interpolates the entire result into the user-facing error. This includes the compiler command line, executable and diagnostics paths, cached state, and captured compiler output.

The plugin runner already surfaces the actionable compiler diagnostic separately, so including the structured result is noisy, exposes implementation details, and can duplicate compiler output.

Changes

  • Replace the interpolated compilation result with a concise plugin compilation failed message.
  • Add focused unit coverage for the compilation failure description.
  • Extend the existing build-tool compiler regression test to verify that:
    • The actionable compiler diagnostic remains visible.
    • PluginCompilationResult and its internal fields are not included.
    • The behavior is covered by both the native and SwiftBuild backends.

Alternatives considered

Customizing PluginCompilationResult’s debug representation was considered. However, the result contains structured compilation state that should not be part of a user-facing diagnostic.

Routing compiler output through additional build-system delegates was also considered. This is no longer necessary because #10346 centralized compiler-output handling in the plugin script runner and already covers diagnostic visibility and verbosity behavior.

Notes

The PluginCompilationResult remains attached to the error and available to callers. This change only prevents its debug representation from being rendered directly to users.

Successful plugin compilation and compiler-diagnostic visibility are unchanged.

Testing

  • swift test --filter PluginInvocationTests.testCompilationFailureDescriptionDoesNotIncludeDebugResult --filter buildToolPluginCompilerErrorIsVisible
  • The focused unit test passed.
  • The command-level regression test passed for both native and SwiftBuild.

What changed:
- Replace the interpolated PluginCompilationResult with a concise compilation failure message.

Why:
- Issue swiftlang#8091 exposes internal command lines, paths, and captured compiler output in a user-facing error.
- The script runner now prints actionable compiler diagnostics separately.

Alternatives considered:
- Customizing the result debug description was rejected because structured compilation state should not be part of a user-facing diagnostic.
What changed:
- Add focused unit coverage for the plugin compilation failure description.
- Extend the existing build-tool regression test to reject leaked internal result fields.

Why:
- Issue swiftlang#8091 is an output-formatting regression that should not expose internal compilation state.
- Reusing upstream coverage keeps native and SwiftBuild behavior covered without duplicate fixtures.

Alternatives considered:
- Keeping separate fixtures and verbosity scenarios was rejected because upstream PR swiftlang#10346 now covers diagnostic visibility and verbosity.
@bripeticca

Copy link
Copy Markdown
Contributor

@swift-ci test

@agisilaos

Copy link
Copy Markdown
Contributor Author

@bripeticca Thanks for triggering CI.

I took some time and I reviewed the three failures and they appear unrelated:

  • Windows timed out while cloning dependencies,
  • Windows self-hosted hung after completing all XCTest cases (the same pattern appears in adjacent jobs),
  • macOS failed in swift-format’s ConfigurationTests.
  • The Linux/macOS SwiftPM jobs and the focused native/SwiftBuild tests pass.

Would you mind taking a look or rerunning the external jobs when convenient?

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.

Plugin build diagnostics are badly formatted

2 participants