Skip to content

fix(linting): give _IP variables a valid address placeholder - #84

Merged
owine merged 1 commit into
mainfrom
fix/env-helpers-ip-placeholder
Aug 25, 2026
Merged

fix(linting): give _IP variables a valid address placeholder#84
owine merged 1 commit into
mainfrom
fix/env-helpers-ip-placeholder

Conversation

@owine

@owine owine commented Aug 25, 2026

Copy link
Copy Markdown
Owner

Problem

create_temp_env synthesises placeholder values from the variable name so docker compose config can run without real secrets. No arm produced a valid IP address, so a name like TAILSCALE_IP fell through to the catch-all and became placeholder_value.

That is harmless where the value is only an environment string — which is why NETWORK_OPTIMIZER_HOST_IP has never tripped it — but it fails validation outright the moment such a variable is used as a bind address:

ports:
  - "${TAILSCALE_IP}:8191:8191"
invalid IP address: placeholder_value

This is currently blocking owine/docker-piwine#1190.

Change

Add an arm yielding 127.0.0.1:

*_IP|*_IP_ADDRESS|IP)
  echo "${var}=127.0.0.1" >> "$temp_env_file"
  ;;

Two deliberate details:

  • Placed before *URL*|*HOST* so names like NETWORK_OPTIMIZER_HOST_IP resolve to an address instead of http://localhost:8080. Without this ordering the *HOST* glob wins.
  • Anchored to the _IP suffix. A bare *IP* glob would also match unrelated names — RECIPIENT_EMAIL contains IP.

Verification

  • shellcheck clean.
  • Regenerated placeholders for all 14 docker-piwine stacks and ran docker compose config against each — all pass, including network-optimizer, whose placeholder this reorders.
  • Confirmed the target case now renders host_ip: 127.0.0.1 instead of failing.

Summary by Sourcery

Generate valid IP address placeholders for linting environment variables.

Bug Fixes:

  • Generate valid loopback IP placeholders for variables ending in _IP or _IP_ADDRESS, allowing Docker Compose validation of bind-address configurations.

Enhancements:

  • Prioritize IP-specific placeholder handling over URL and host matching to ensure host IP variables receive address values.

create_temp_env synthesises placeholder values from the variable name so
that docker compose config can run without real secrets. No arm produced a
valid IP address, so a name like TAILSCALE_IP fell through to the catch-all
and became "placeholder_value". That is harmless where the value is only an
environment string, but it fails validation outright when the variable is
used as a bind address:

  ports:
    - "${TAILSCALE_IP}:8191:8191"    ->  invalid IP address: placeholder_value

Add an arm yielding 127.0.0.1. It is placed before *URL*|*HOST* so that
names like NETWORK_OPTIMIZER_HOST_IP resolve to an address rather than a
URL, and is anchored to the _IP suffix because a bare *IP* glob would also
match unrelated names such as RECIPIENT_EMAIL.

Verified with shellcheck, and by regenerating placeholders for all 14
docker-piwine stacks and running docker compose config against each: all
pass, including network-optimizer, whose placeholder this reorders.
@sourcery-ai

sourcery-ai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates temporary environment generation so IP address variables receive 127.0.0.1, preventing Docker Compose bind-address validation failures while preserving URL/host handling and avoiding overly broad matches.

Flow diagram for temporary IP placeholder selection

flowchart TD
    A[create_temp_env receives variable name] --> B{Matches *_IP, *_IP_ADDRESS, or IP?}
    B -->|Yes| C[Write 127.0.0.1 to temp env file]
    B -->|No| D{Matches *URL* or *HOST*?}
    D -->|Yes| E[Write http://localhost:8080 to temp env file]
    D -->|No| F[Apply existing placeholder rules]
Loading

File-Level Changes

Change Details Files
Generate a valid loopback address for IP-named temporary environment variables.
  • Match variables ending in _IP, _IP_ADDRESS, or exactly IP.
  • Emit 127.0.0.1 instead of the generic placeholder.
  • Place the IP rule before URL/host matching to handle names such as NETWORK_OPTIMIZER_HOST_IP.
  • Keep matching anchored to avoid incorrectly classifying names such as RECIPIENT_EMAIL.
scripts/linting/lib/env-helpers.sh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@owine
owine merged commit c346d79 into main Aug 25, 2026
3 checks passed
@owine
owine deleted the fix/env-helpers-ip-placeholder branch August 25, 2026 16:02

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant