nzbgetcom / nzbget

efficient usenet downloader
https://nzbget.com
GNU General Public License v2.0
306 stars 16 forks source link

Variable truncation in bash breaks all addons since v23 #367

Closed nomandera closed 1 week ago

nomandera commented 2 weeks ago

Is there already an issue for your problem?

NZBGet Version

v24.2-stable

Platform

Linux/Docker

Environment

Docker 64bit

Current Behavior

Somewhere between:

https://github.com/nzbgetcom/nzbget/commit/4e4d9f590cd6b59d314fd2bd002176ca70cb4f52 and https://github.com/nzbgetcom/nzbget/commit/7f68f557d888b237fffd7cd8ea3231edf2fc7a15

a bug was introduced that as far as I can tell causes all user defined variable names in bash addons to truncate the first character

image

If you roll between v22 and v23 you can see this work and fail.

Expected Behavior

ENV should match script variables

Steps To Reproduce

Install this sample addon

#!/bin/bash
# post-processing script to test for ENV truncation

################################################################################
### NZBGET POST-PROCESSING SCRIPT                                            ###

# We expect VAR name and VAR contents to match

################################################################################
### OPTIONS                                                                  ###

# HELLO
hello=hello

# GOODBYE
goodbye=goodbye

### NZBGET POST-PROCESSING SCRIPT                                            ###
################################################################################

echo "NZBPO_HELLO: $NZBPO_HELLO"
echo "NZBPO_ELLO: $NZBPO_ELLO"
echo "NZBPO_GOODBYE: $NZBPO_GOODBYE"
echo "NZBPO_OODBYE: $NZBPO_OODBYE"
printenv

# 93 is code for success
exit 93

review UI and addon logs for the dropped h and g for this addon ENVs

Logs

info    Wed Aug 28 2024 19:19:48    testtruncation: NZBPO_oodbye=goodbye
info    Wed Aug 28 2024 19:19:48    testtruncation: NZBOP_TESTTRUNCATION_OODBYE=goodbye
info    Wed Aug 28 2024 19:19:48    testtruncation: NZBPO_OODBYE=goodbye
info    Wed Aug 28 2024 19:19:48    testtruncation: NZBOP_testtruncation:oodbye=goodbye
info    Wed Aug 28 2024 19:19:48    testtruncation: NZBPO_OODBYE: goodbye
info    Wed Aug 28 2024 19:19:48    testtruncation: NZBPO_GOODBYE:

Extra information

No response

dnzbk commented 2 weeks ago

According to the old documentation, it's required to use the # symbol and no spaces with options. Example:

# SMTP server host.
#Server=smtp.gmail.com

# SMTP server port (1-65535).
#Port=25

Apparently, your case has worked before too, but in an implicit way, which caused the confusion.

Please consider using the new v2 extensions as they are more flexible and predictable.

nomandera commented 2 weeks ago

Thanks for getting back to me so quickly. This # requirement is completely new information to me and explains so much.

I have been using the same simple bash template as a base for creating adhoc addons for as long as I can remember (well over a decade?) and I assume somewhere in there either this changed or I was wrong all along and it just happened to work.

I also had no clue that v2 extensions were a thing.

I will test the # fix and close this ticket when solved today and look to porting to v2 imminently.

nomandera commented 1 week ago

Fix confirmed. Thanks for the assist.