Skip to content

fix(nodeenv): raise on bad config references again - #458

Merged
ekalinin merged 1 commit into
ekalinin:masterfrom
r3wretrhy:fix-config-interpolation-errors
Oct 31, 2026
Merged

ekalinin merged 1 commit into
ekalinin:masterfrom
r3wretrhy:fix-config-interpolation-errors

Conversation

@r3wretrhy

@r3wretrhy r3wretrhy commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #456

#449 fell back to the raw value on any InterpolationError, so a typo in a %(name)s reference or a reference loop was read as written and failed later with a confusing download error. This catches only InterpolationSyntaxError, which is what a stray % such as a percent-encoded mirror login raises. The #440 cases still read as before.

I added tests for the missing-key and reference-loop cases; both fail on master. tox checks pass locally (pytest without integration tests and flake8, Python 3.13).

  • Tests cover the change
  • tox passes: the tests and flake8
  • CHANGES has an entry under Version [unreleased], if nodeenv's
    behavior changes
  • README.rst is updated, if the change affects what it documents
  • The title has the form type(scope): subject

@ekalinin ekalinin left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for the patch! Three things before merge.

  • A typo in the reference syntax itself still gets through: %(base)/nodejs (no s) raises InterpolationSyntaxError, so it is still read as written. Falling back only when the value has no %( covers it:

                        except InterpolationSyntaxError:
                            # A percent-encoded mirror login, #440
                            val = ini_file.get(section, attr, raw=True)
                            if '%(' in val:
                                raise

    A percent-encoded URL never has %(, so %40 and %%40 still give %40, and a value with a %(name)s reference and a stray % raises, as it did before #449. A ('%(base)/nodejs', configparser.InterpolationSyntaxError) case in test_config_reports_bad_references would pin it. I checked it on a copy of master's nodeenv.py: that case fails with this branch's change and passes with the two lines.

  • The #440 entry in CHANGES says "a value that can't be interpolated is read as written", which is no longer true now that a missing key or a loop raises again. Something like:

    - A ``%`` in a ``[nodeenv]`` config value, such as a percent-encoded
      mirror login, no longer crashes nodeenv: a value that can't be
      interpolated and has no ``%(name)s`` reference is read as written.
      ``%%`` still gives ``%``, which ``setup.cfg`` needs, as setuptools
      reads that file too
      `#440 <https://github.com/ekalinin/nodeenv/issues/440>`_
  • Please rebase on master: #459 added import _thread on the line where this PR adds import configparser, so the branch conflicts now.

@r3wretrhy
r3wretrhy force-pushed the fix-config-interpolation-errors branch from f4013f2 to ff4f140 Compare October 31, 2026 13:49
@r3wretrhy

Copy link
Copy Markdown
Contributor Author

Thanks, all three done in ff4f140:

  • the fallback now re-raises when the raw value has %(, and ('%(base)/nodejs', configparser.InterpolationSyntaxError) is in test_config_reports_bad_references. It passes, and %40 / %%40 still give %40.
  • reworded the A % in a [nodeenv] config value crashes nodeenv #440 entry in CHANGES as you suggested.
  • rebased on master, keeping both import _thread and import configparser.

@ekalinin
ekalinin merged commit c2e21d0 into ekalinin:master Oct 31, 2026
26 checks passed
@ekalinin ekalinin added the bug label Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A bad %(name)s reference in a config value no longer raises an error

2 participants