Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packit fails with UnterminatedMacroException if %changelog contains % charater #386

Closed
1 of 2 tasks
bmr-cymru opened this issue Jun 20, 2024 · 0 comments · Fixed by #387
Closed
1 of 2 tasks

Packit fails with UnterminatedMacroException if %changelog contains % charater #386

bmr-cymru opened this issue Jun 20, 2024 · 0 comments · Fixed by #387
Labels
kind/bug Something isn't working.

Comments

@bmr-cymru
Copy link

What happened? What is the problem?

UnterminatedMacroException occurred during package build:

https://download.copr.fedorainfracloud.org/results/packit/snapshotmanager-snapm-59/srpm-builds/07630034/builder-live.log.gz

2024-06-20 14:44:55.997 utils.py          ERROR  Preparation of the repository for creation of an SRPM failed: 
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/specfile/value_parser.py", line 252, in parse
    if value[end + 1] == "%":
       ~~~~~^^^^^^^^^
IndexError: string index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/packit/api.py", line 1739, in prepare_sources
    self.up.prepare_upstream_for_srpm_creation(
  File "/usr/lib/python3.12/site-packages/packit/upstream.py", line 644, in prepare_upstream_for_srpm_creation
    SRPMBuilder(upstream=self, ref=upstream_ref).prepare(
  File "/usr/lib/python3.12/site-packages/packit/upstream.py", line 1195, in prepare
    self._fix_specfile_to_use_local_archive(
  File "/usr/lib/python3.12/site-packages/packit/upstream.py", line 1173, in _fix_specfile_to_use_local_archive
    self.upstream.fix_spec(
  File "/usr/lib/python3.12/site-packages/packit/upstream.py", line 550, in fix_spec
    ).prepare_upstream_locally(
      ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/packit/utils/changelog_helper.py", line 295, in prepare_upstream_locally
    self.up.specfile.add_changelog_entry(msg)
  File "/usr/lib/python3.12/site-packages/specfile/specfile.py", line 487, in add_changelog_entry
    if self.contains_autochangelog(section):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/specfile/specfile.py", line 436, in contains_autochangelog
    for node in ValueParser.flatten(ValueParser.parse(line)):
                                    ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/specfile/value_parser.py", line 256, in parse
    raise UnterminatedMacroException
specfile.exceptions.UnterminatedMacroException

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/packit/cli/utils.py", line 47, in covered_func
    func(config=config, *args, **kwargs)  # noqa: B026
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/packit/cli/utils.py", line 143, in covered_func
    func(*args, **decorated_func_kwargs)
  File "/usr/lib/python3.12/site-packages/packit/cli/prepare_sources.py", line 193, in prepare_sources
    api.prepare_sources(
  File "/usr/lib/python3.12/site-packages/packit/api.py", line 1747, in prepare_sources
    raise PackitSRPMException(

This was due to '%' character appearing in the package ChangeLog:

Workaround:

diff --git a/snapm.spec b/snapm.spec
index b04a24c..0e2aedb 100644
--- a/snapm.spec
+++ b/snapm.spec
@@ -186,17 +186,17 @@ rm doc/conf.py
 - snapm.Snapshot: remove useless class variables
 - snapm: command line support for default size policy
 - snapm: support default size policy in Manager.create_snapshot_set()
-- snapm: also cap %FREE size policies to <=100%
+- snapm: also cap FREE size policies to <=100
 - tests: test snapm.is_size_policy()
 - lvm2: fix free space accounting for multiple VGs
 - tests: add basic tests for SizePolicy class
 - doc: add basic documentation for size policies to README.md
 - tests: fix ManagerTests::test_create_snapshot_set_no_space_raises
 - lvm2: fix free space accounting in Lvm2Cow._check_free_space()
-- snapm: cap PERCENT_SIZE policy to 100% of device size
-- snapm: fix %FREE space accounting
+- snapm: cap PERCENT_SIZE policy to 100 of device size
+- snapm: fix FREE space accounting
 - Add Plugin.{start,end}_transaction()
-- Make default SizePolicy 200%USED
+- Make default SizePolicy 200USED
 - snapm: implement size control policies in manager and plugins
 - snapm: add size control policy infrastructure
 - lvm2: improve error message when snapshot creation fails

What did you expect to happen?

No exception. Any '%' characters in the changelog are not treated as RPM macros.

Example URL(s)

https://download.copr.fedorainfracloud.org/results/packit/snapshotmanager-snapm-59/srpm-builds/07630034/builder-live.log.gz

Steps to reproduce

1. Add entry to changelog with "%TEXT"
2. Attempt packit build
3. SRPM build fails with above exception

Workaround

  • There is an existing workaround that can be used until this issue is fixed.

Participation

  • I am willing to submit a pull request for this issue. (Packit team is happy to help!)
@lbarcziova lbarcziova added the kind/bug Something isn't working. label Jun 24, 2024
@lbarcziova lbarcziova transferred this issue from packit/packit Jun 24, 2024
@nforro nforro moved this from new to in-review in Packit Kanban Board Jun 24, 2024
softwarefactory-project-zuul bot added a commit that referenced this issue Jun 24, 2024
…387)

Ignore unparseable %changelog lines when checking for %autochangelog

Fixes #386.
RELEASE NOTES BEGIN
Fixed an exception that occured when accessing the Specfile.has_autochangelog property while having unparseable lines (e.g. lines ending with unescaped %) in %changelog.
RELEASE NOTES END

Reviewed-by: Laura Barcziová
@github-project-automation github-project-automation bot moved this from in-review to done in Packit Kanban Board Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants