Skip to content

ddns-scripts: fix netcup.com for multiple runs#29098

Open
flubshi wants to merge 1 commit intoopenwrt:masterfrom
flubshi:fix/ddns_netcup.com
Open

ddns-scripts: fix netcup.com for multiple runs#29098
flubshi wants to merge 1 commit intoopenwrt:masterfrom
flubshi:fix/ddns_netcup.com

Conversation

@flubshi
Copy link
Copy Markdown

@flubshi flubshi commented Apr 8, 2026

📦 Package Details

Maintainer: @feckert
(You can find this by checking the history of the package Makefile.)

Description:

This PR fixes an issue where the netcup DDNS update script fails on subsequent runs due to reassigning a readonly variable. The variable has been changed to a regular assignment to ensure the script can be sourced multiple times without errors.

Additionally, error handling has been improved:

  • Several hard failures (write_log 14) have been replaced with soft failures (return 1) to allow the ddns framework to retry updates according to the configured retry policy.
  • Hard failures are now reserved for critical issues such as missing dependencies or invalid configuration.
  • JSON parsing has been made more robust by replacing cat-based loading with json_load_file, which is the intended method for handling JSON input in this context.

🧪 Run Testing Details

  • OpenWrt Version: OpenWrt 25.12.2 r32802-f505120278
  • OpenWrt Target/Subtarget:
  • OpenWrt Device: TP-Link Archer C7 v4

✅ Formalities

  • I have reviewed the CONTRIBUTING.md file for detailed contributing guidelines.

If your PR contains a patch:

  • It can be applied using git am
  • It has been refreshed to avoid offsets, fuzzes, etc., using
    make package/<your-package>/refresh V=s
  • It is structured in a way that it is potentially upstreamable
    (e.g., subject line, commit description, etc.)
    We must try to upstream patches to reduce maintenance burden.

The netcup ddns update script fails on a second run, because a readonly
variable is assigned again. This is fixed by removing the readonly.
Multiple hard-failures were replaced by soft-failure, to allow ddns to
retry after specified retry timeout. Hard failure should only happen on
essential failures like missing dependencies or credentials.
Loading JSON from file is improved by using the function intended for
this purpose instead of using cat to pass file content.

Signed-off-by: Tim Flubshi <flubshi@gmail.com>
@BKPepe BKPepe requested a review from Copilot April 8, 2026 21:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes repeatability and retry behavior of the netcup.com DDNS updater by removing a readonly reassignment error, improving JSON loading, and converting several hard-fail exits into retryable failures.

Changes:

  • Make __NETCUP_ENDPOINT re-source-safe by removing readonly assignment.
  • Use json_load_file for parsing the provider response stored in $DATFILE.
  • Convert several hard failures into return 1 paths to allow ddns framework retries.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
net/ddns-scripts/files/usr/lib/ddns/update_netcup_com.sh Makes the netcup updater safe to source multiple times; improves JSON loading and makes several failures retryable.
net/ddns-scripts/Makefile Bumps package release to publish the behavior fixes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# ---------------------------------------------------------------------------

readonly __NETCUP_ENDPOINT="https://ccp.netcup.net/run/webservice/servers/endpoint.php?JSON"
__NETCUP_ENDPOINT="https://ccp.netcup.net/run/webservice/servers/endpoint.php?JSON"
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

Dropping readonly fixes re-sourcing, but it also makes this constant mutable for the rest of the shell lifetime. Consider keeping it effectively constant without triggering reassignment errors by assigning only if unset (or once) and then using readonly __NETCUP_ENDPOINT without an = assignment. This preserves the original intent (constant endpoint) while remaining safe across multiple sourcing.

Suggested change
__NETCUP_ENDPOINT="https://ccp.netcup.net/run/webservice/servers/endpoint.php?JSON"
: "${__NETCUP_ENDPOINT:=https://ccp.netcup.net/run/webservice/servers/endpoint.php?JSON}"
readonly __NETCUP_ENDPOINT

Copilot uses AI. Check for mistakes.
netcup_post || write_log 14 "netcup DDNS: HTTP request failed during login"
netcup_check_response "login"
if ! netcup_post; then
write_log 3 "netcup DDNS: HTTP request failed during login"
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

On early-return paths after building a JSON request, the json.sh internal state is left as-is. Add json_cleanup before return 1 in these netcup_post failure branches (login/infoDnsRecords/updateDnsRecords) to avoid leaking JSON state into subsequent retries within the same process.

Suggested change
write_log 3 "netcup DDNS: HTTP request failed during login"
write_log 3 "netcup DDNS: HTTP request failed during login"
json_cleanup

Copilot uses AI. Check for mistakes.
Comment on lines +159 to +162
if ! netcup_post; then
write_log 3 "netcup DDNS: HTTP request failed during login"
return 1
fi
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

When netcup_post fails, the log message does not include the underlying transport/tool error even though stderr is redirected to $ERRFILE in netcup_post. Consider appending the captured error output (or a short excerpt) to the log message to make retry failures diagnosable without increasing log level globally.

Copilot uses AI. Check for mistakes.
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.

3 participants