Skip to content

[bug] Monorepo path_filters fails to reference paths outside the current package subtree #1380

Closed

Description

@guillaumecherel

Question

In a monorepo with structure like:

./
- src/: shared code
- projects
  - api/
    - pyproject.toml
    - src/
  - <other packages>
    - ...

I’d like any change in src/ to be reflected as a change of the package in projects/api by setting path_filters like:

[tool.semantic_release.commit_parser_options]
path_filters = [".", "../../src"]

But modifications in src/ don’t get added to the generated changelog:

touch src/test.txt
git add .
git commit -m "fix: test"
cd projects/api
semantic-release -v --noop version

Should I not rely on path filters to include such changes in code shared by multiple packages ?

Configuration

Semantic Release Configuration
[tool.semantic_release]
commit_parser = "conventional-monorepo"
commit_message = """\
chore(release): api@{version}`

Automatically generated by python-semantic-release
"""
tag_format = "api-v{version}"
version_toml = ["pyproject.toml:project.version"]
build_command = """
    uv lock --upgrade-package "$PACKAGE_NAME"
    git add ../../uv.lock
"""

[tool.semantic_release.commit_parser_options]
path_filters = [".", "../../src"]
scope_prefix = "api-"

[tool.semantic_release.changelog]
# Recommended patterns for conventional commits parser that is scope aware
exclude_commit_patterns = [
    '''^chore(?:\([^)]*?\))?: .+''',
    '''^ci(?:\([^)]*?\))?: .+''',
    '''^refactor(?:\([^)]*?\))?: .+''',
    '''^style(?:\([^)]*?\))?: .+''',
    '''^test(?:\([^)]*?\))?: .+''',
    '''^build\((?!deps\): .+)''',
    '''^Initial [Cc]ommit.*''',
]
mode = "update"
insertion_flag = "<!-- python-semantic-release insertion_flag -->"

[tool.semantic_release.changelog.default_templates]
changelog_file = "../../docs/api/changelog.md"
output_format = "md"

Additional context

git log --oneline --decorate --graph --all -n 50

Activity

  1. guillaumecherel commented on Nov 25, 2025

    @guillaumecherel
    ContributorAuthor

    I tried writing a PR but couldn’t get far enough to test it. I hope it can help anyway otherwise just discard it.

  2. codejedi365 commented on Nov 25, 2025

    @codejedi365
    Contributor

    Yes, path filters does work outside of the package where it is defined. It is important to make sure that the current working directory is where your configuration is so that the file paths are resolved properly.

    See my example repository, codejedi365/psr-monorepo-poweralpha, where the documentation is tracked outside of the package directory.

  3. added and removed
    triagewaiting for initial maintainer review
    on Nov 25, 2025
  4. guillaumecherel commented on Nov 25, 2025

    @guillaumecherel
    ContributorAuthor

    Thanks!

    I did take care of moving into the same directory as the package.

    I experimented with your example repository. I noticed that it uses a custom commit parser directly included in the repository. I tried using the builtin conventional-monorepo instead and that reproduced my issue. Here are steps to reproduce.

    git clone [email protected]:codejedi365/psr-monorepo-poweralpha.git
    cd psr-monorepo-poweralpha/poweralpha/services/srvc1
    

    Let’s add a file in a directory that is tracked by path_filters in the current pyproject.toml, and commit it:

    echo a >> ../../../documentation/docs/srvc1/a.txt
    git add ../../../
    git commit -m "fix: testing path_filters"
    semantic-release -v --noop version
    

    The output ends with the changelog containig the latest commit as expected:

    ...
    ### Bug Fixes
    
    - Testing path_filters 
    ([`e9ff1c8`](https://github.com/codejedi365/psr-monorepo-poweralpha/commit/e9ff1c8d316817c771254b7ab204b
    4dcf826b00e))
    
    ---
    
    **Detailed Changes**: 
    [srvc1-v1.2.1...srvc1-v1.2.2](https://github.com/codejedi365/psr-monorepo-poweralpha/compare/srvc1-v1.2.
    1...srvc1-v1.2.2)
    

    Now edit pyproject.toml to replace

    commit_parser = "../../../scripts/custom_parser/monorepo_parser.py:ConventionalCommitMonorepoParser"
    

    with

    commit_parser = "conventional-monorepo"
    

    and re-run

    semantic-release -v --noop version
    

    Now the output is:

     🛡 You are running in no-operation mode, because the '--noop' flag was supplied
    [21:15:31] INFO     Loading configuration from pyproject.toml                                 util.py:77
    WARNING:root:Found .git/ in higher parent directory rather than provided in configuration.
               INFO     Using group 'main' options, as '(main|master)' matches 'main'          config.py:590
    INFO:semantic_release:Using group 'main' options, as '(main|master)' matches 'main'
               WARNING  Token value is missing!                                                config.py:782
    WARNING:semantic_release:Token value is missing!
               INFO     found 4 previous tags                                                algorithm.py:60
    INFO:semantic_release:found 4 previous tags
               INFO     The last full version in this branch's history was 1.2.1            algorithm.py:298
    INFO:semantic_release:The last full version in this branch's history was 1.2.1
               INFO     The latest release in this branch's history was 1.2.1               algorithm.py:328
    INFO:semantic_release:The latest release in this branch's history was 1.2.1
               INFO     Found 2 commits since the last release!                             algorithm.py:340
    INFO:semantic_release:Found 2 commits since the last release!
               INFO     The type of the next release release is: no_release                 algorithm.py:384
    INFO:semantic_release:The type of the next release release is: no_release
               INFO     No release will be made                                             algorithm.py:392
    INFO:semantic_release:No release will be made
    1.2.1
               INFO     found 4 previous tags                                                algorithm.py:60
    INFO:semantic_release:found 4 previous tags
    No release will be made, 1.2.1 has already been released!
               INFO     not writing GitHub Actions output, as no file specified github_actions_output.py:161
    INFO:semantic_release:not writing GitHub Actions output, as no file specified
    

    It looks like the latest commit was not selected for the next release.

  5. codejedi365 commented on Nov 26, 2025

    @codejedi365
    Contributor

    Well that's odd. Will have to look into it further. There is not much difference between the two as I wrote the custom parser first and then published it as conventional-monorepo with very little refactoring.

  6. added
    needs-updateNeeds status update from maintainers
    and removed on Nov 26, 2025
  7. guillaumecherel commented on Dec 1, 2025

    @guillaumecherel
    ContributorAuthor

    I think I’ve figured it out and my PR was not the right fix.

    I realized that the pydantic field validators for path_filters weren’t being executed:


    and

    When I swapped the @classmethod and @field_validator decorators everywhere to make sure the latter is applied on top of the former, they get executed.

    Then I got validation errors because the validators return Paths but your type annotations expect strings:

    path_filters: Annotated[Tuple[str, ...], Field(validate_default=True)] = (".",)

    Finally, after changing str to Path, I had to make a small change in the parser to work with paths rather than strings.

    Everything seems alright now. I’m updating my PR

  8. added a commit that references this issue on Dec 14, 2025
    24ad90a
  9. added
    bugSomething isn't working properly
    and removed
    needs-updateNeeds status update from maintainers
    on Dec 14, 2025
  10. added a commit that references this issue on Dec 14, 2025
    a51eadd
  11. changed the title [-]Can path_filters reference paths outside the current package subtree ?[/-] [+][bug] Monorepo `path_filters` fails to reference paths outside the current package subtree[/+] on Dec 14, 2025
  12. codejedi365 commented on Dec 14, 2025

    @codejedi365
    Contributor

    🎉 This issue has been resolved in v10.5.3 🎉

    You can find more information about this release on the GitHub Releases page.

    If your issue persists, please reply here and we will re-open the issue. If you receive a new error, please open a new issue and reference this issue there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working properlyreleased

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions