PBR

"IndexError: string index out of range" in version.from_pip_string

Bug #1570145 reported by Jeremy Stanley
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
PBR
Fix Released
Critical
R. Nortman

Bug Description

[reported on behalf or R. Nortman (r-nortman)]

Changelog parsing changed between 1.8.1 and 1.9.0 with https://review.openstack.org/263748 "Split changelog on nulls instead of (" and now some tag patterns cause the following traceback:

  [pbr] Writing ChangeLog
  [pbr] Generating ChangeLog
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-f3fao6-build/setup.py", line 29, in <module>
      pbr=True)
    File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
      dist.run_commands()
    File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
      self.run_command(cmd)
    File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
      cmd_obj.run()
    File "/home/rnortman/.virtualenvs/testpbr/local/lib/python2.7/site-packages/wheel/bdist_wheel.py", line 211, in run
      self.run_command('install')
    File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
      self.distribution.run_command(command)
    File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
      cmd_obj.run()
    File "/home/rnortman/.virtualenvs/testpbr/local/lib/python2.7/site-packages/pbr/packaging.py", line 195, in run
      _from_git(self.distribution)
    File "/home/rnortman/.virtualenvs/testpbr/local/lib/python2.7/site-packages/pbr/packaging.py", line 485, in _from_git
      git.write_git_changelog(option_dict=option_dict, changelog=changelog)
    File "/home/rnortman/.virtualenvs/testpbr/local/lib/python2.7/site-packages/pbr/git.py", line 261, in write_git_changelog
      for release, content in changelog:
    File "/home/rnortman/.virtualenvs/testpbr/local/lib/python2.7/site-packages/pbr/git.py", line 156, in _iter_changelog
      for hash, tags, msg in changelog:
    File "/home/rnortman/.virtualenvs/testpbr/local/lib/python2.7/site-packages/pbr/git.py", line 230, in _iter_log_inner
      if _is_valid_version(candidate):
    File "/home/rnortman/.virtualenvs/testpbr/local/lib/python2.7/site-packages/pbr/git.py", line 192, in _is_valid_version
      version.SemanticVersion.from_pip_string(candidate)
    File "/home/rnortman/.virtualenvs/testpbr/local/lib/python2.7/site-packages/pbr/version.py", line 200, in from_pip_string
      if remainder and (remainder[0][0] == '0' or
  IndexError: string index out of range

Revision history for this message
Robert Collins (lifeless) wrote :

This is simple: from_pip_string should have a try:except IndexError: raise ValueError around its entire body, or at least any suspect/unguarded regions.

Revision history for this message
R. Nortman (r-nortman) wrote :

Minimal test case: a git tag of the form "1_foo.1" will trigger the above stack trace.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to pbr (master)

Fix proposed to branch: master
Review: https://review.openstack.org/305550

Changed in pbr:
assignee: nobody → R. Nortman (r-nortman)
status: New → In Progress
Revision history for this message
Sachi King (nakato) wrote :

This bug is partially related to PBR Bug#1452515

https://bugs.launchpad.net/pbr/+bug/1452515

Changed in pbr:
importance: Undecided → Critical
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to pbr (master)

Reviewed: https://review.openstack.org/305550
Committed: https://git.openstack.org/cgit/openstack-dev/pbr/commit/?id=a27f51242b041f8afd79d4fa2d4d6eaf1dda9f0c
Submitter: Jenkins
Branch: master

commit a27f51242b041f8afd79d4fa2d4d6eaf1dda9f0c
Author: Randall Nortman <email address hidden>
Date: Wed Apr 13 21:05:07 2016 -0400

    Handle IndexError during version string parsing

    Some odd version strings can cause SemanticVersion.from_pip_string()
    to raise IndexError. This change converts IndexError to ValueError.

    Change-Id: Ic3046817b6c5808c61c4a3bc3d912501e6a52274
    Closes-Bug: #1570145

Changed in pbr:
status: In Progress → Fix Released
Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote : Fix included in openstack-dev/pbr 1.9.1

This issue was fixed in the openstack-dev/pbr 1.9.1 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on pbr (master)

Change abandoned by ChangBo Guo(gcb) (<email address hidden>) on branch: master
Review: https://review.openstack.org/305080
Reason: Please restore it if you want to continue working on this.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.