Skip to content

Conversation

@llucax
Copy link
Contributor

@llucax llucax commented Jun 16, 2025

Fix wrong passing of include paths when passed via:

  • Command-line: Now extra white-spaces and empty strings are removed, before they were passed to protoc -I.
  • pyproject.toml: Now an empty array/list can be passed to override the default paths, before this resulted in an empty string being passed to protoc -I.

Copilot AI review requested due to automatic review settings June 16, 2025 10:16
@llucax llucax requested a review from a team as a code owner June 16, 2025 10:16
@github-actions github-actions bot added part:docs Affects the documentation part:protobuf Affects the protobuf tools labels Jun 16, 2025
@llucax llucax self-assigned this Jun 16, 2025
@llucax llucax added this to the v0.13.5 milestone Jun 16, 2025
@llucax llucax added the type:bug Something isn't working label Jun 16, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the issue of passing empty or whitespace-only include paths to protoc by properly processing include paths passed via the command line or pyproject.toml.

  • Update include_paths type annotation to accept both a string and an iterable of strings.
  • Process include_paths using a pattern matching construct to remove extra white-spaces and empty strings.
  • Update RELEASE_NOTES.md to document these changes.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/frequenz/repo/config/setuptools/grpc_tools.py Refactored include_paths handling to support both string and iterable inputs.
RELEASE_NOTES.md Updated notes to reflect the fix in passing include paths to protoc.

@llucax
Copy link
Contributor Author

llucax commented Jun 16, 2025

Sadly no tests because we still have no tests for this, as it is complicated because this is a setuptools plugin. I plan to move this to a separate repo in the future, which can make writing some integration test for it more easily.

Manually tested with frequenz-floss/frequenz-api-common#374.

@llucax llucax enabled auto-merge June 16, 2025 10:17
llucax added 3 commits June 16, 2025 12:42
When loading protobuf include paths from the pyproject.toml file, the
paths are received as an array/list. If we convert them to
a comma-separated string there is the risk of a path containing commas
to be split incorrectly, leading to compilation errors.

Using the original array/list of paths instead of a comma-separated
string is safer and more flexible.

Signed-off-by: Leandro Lucarella <[email protected]>
When include paths are passed via the commnad-line, they are passed as
a comma-separated string. This means the user could add extra spaces or
pass a double-comma, which would result in empty strings in the
include paths list, making the protobuf compiler fail.

This commit cleans the include paths by stripping whitespace and
ignoring empty strings.

Signed-off-by: Leandro Lucarella <[email protected]>
Signed-off-by: Leandro Lucarella <[email protected]>
@llucax
Copy link
Contributor Author

llucax commented Jun 16, 2025

Rebased and fixed release notes conflicts, needs a new approval, but probably from the @frequenz-floss/python-sdk-team to be able to be queued for merging.

@llucax llucax merged commit f93e20f into frequenz-floss:v0.13.x Jun 16, 2025
5 checks passed
@llucax llucax deleted the fix-protobuf-I branch June 16, 2025 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:docs Affects the documentation part:protobuf Affects the protobuf tools part:template Affects the cookiecutter template files type:bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants