luci-app-https-dns-proxy: fix get_providers() invalid JSON in directory fallback#8648
luci-app-https-dns-proxy: fix get_providers() invalid JSON in directory fallback#8648unglazed7010 wants to merge 1 commit into
Conversation
…ry fallback
The directory-scan fallback in get_providers() emitted a trailing comma
after every provider file including the last, producing output like:
{"https-dns-proxy":[{...},{...},]}
which is rejected by strict JSON parsers. This code path is taken when
providers.json has not been pre-built, so the LuCI provider list would be
silently empty.
Fix the loop to emit the separator before each entry after the first,
and add [ -f ] guard + *.json glob so an empty or absent directory yields
a valid empty array instead of a broken [ , ] fragment.
Make providersDir/providersJson overridable via _LUCI_PROVIDERS_DIR /
_LUCI_PROVIDERS_JSON environment variables (no-op on production; used
only by the test harness) so the fallback path can be exercised without
touching live system paths.
Add three new tests in section 04 of tests/run_tests.sh:
- directory fallback produces valid JSON across all 45 real providers
- all providers are present in the output (count check)
- empty providers directory yields a valid empty array
Signed-off-by: unglazed7010 <thatblueghoul@gmail.com>
Failed checksIssues marked with an ❌ are failing checks. Commit 727cbdf
For more details, see the full job log. Something broken? Consider providing feedback. |
|
Please direct your PR upstream to: Thanks for your contribution |
openwrt-ai
left a comment
There was a problem hiding this comment.
Reviewed 1 new commit. This PR modifies luci-app-https-dns-proxy, which is maintained out-of-tree at https://github.com/mossdef-org/luci-app-https-dns-proxy and should be submitted there rather than reviewed/merged in openwrt/luci. See the inline comment for details; the underlying fix appears sound but belongs upstream.
Generated by Claude Code
| [ -f "$f" ] || continue | ||
| [ "$first" = "1" ] || printf ',' | ||
| first=0 | ||
| cat "$f" |
There was a problem hiding this comment.
luci-app-https-dns-proxy is maintained out-of-tree, not in openwrt/luci. Changes to this RPC backend (and the accompanying tests) should be submitted to the upstream repository so they don't get overwritten on the next sync: https://github.com/mossdef-org/luci-app-https-dns-proxy
The fix itself looks reasonable (the trailing-comma / [,] bug is real), but it needs to land upstream rather than here. Please redirect this PR there.
Generated by Claude Code
Fixes #8647
Summary
get_providers()emitted a trailing comma after every provider file in the directory-scan fallback, producing JSON rejected by strict parsers and silently breaking the provider list in the UI$providersDircausedcatto fail on a literal glob string while still emitting,, producing[,]Patch
root/usr/libexec/rpcd/luci.https-dns-proxy[ -f "$f" ] || continueguard and narrow glob to*.jsonso an empty/absent directory yields a valid empty array instead of broken output_LUCI_PROVIDERS_DIR/_LUCI_PROVIDERS_JSONenv-var overrides (default unchanged) to make the fallback path exercisable in the test harness without touching live system pathstests/run_tests.shNew section 04 — three tests:
Test run results
(was 332 tests before this patch; all pre-existing tests still pass)
Signed-off-by: unglazed7010 thatblueghoul@gmail.com