jaredhendrickson13 / pfsense-api

The missing REST and GraphQL API package for pfSense
https://pfrest.org/
Apache License 2.0
689 stars 106 forks source link

Installing pfsense-restapi causes "pfSense-upgrade -d -c" to throw a warning #588

Closed mbentley closed 4 days ago

mbentley commented 2 weeks ago

Describe the bug After installing pfsense-restapi, it causes pfSense-upgrade -d -c to throw a warning:

[2.7.2-RELEASE][admin@pfSense.home.arpa]/root: pfSense-upgrade -d -c
pfSense-repoc-static: si_get_packages: failed to run the pkg info command: /usr/local/sbin/pkg-static info -R --raw-format json-compact pfSense-pkg-\* 2>&1
pfSense-repoc-static: no pfSense packages installed
>>> Updating repositories metadata...
Updating pfSense-core repository catalogue...
Fetching meta.conf:
Fetching packagesite.pkg:
pfSense-core repository is up to date.
Updating pfSense repository catalogue...
Fetching meta.conf:
Fetching packagesite.pkg:
pfSense repository is up to date.
All repositories are up to date.
Your system is up to date

This is also present in the UI when looking at the System Update screen:

Before installed: screenshot 2024-10-30 at 9 43 26 AM

After installed: screenshot 2024-10-30 at 9 43 48 AM

Here is the output of /usr/local/sbin/pkg-static info -R --raw-format json-compact pfSense-pkg-\* which it complains about: post.json

I can only guess that maybe there is something that pfSense is not expecting when parsing the output. From what I see from a Netgate forum post, this is just a cosmetic issue and doesn't actually cause any problems but I thought I would report it in case it does eventually cause any issues.

To Reproduce Steps to reproduce the behavior:

  1. Start with a clean pfsense install
  2. Install the v2 package for pfsense-restapi
  3. Check the System Update screen; also visible from the CLI running pfSense-upgrade -d -c
  4. See error

Expected behavior I wouldn't expect this to happen. The v1 pfsense-api package doesn't cause this behavior. Unsure of what is happening when the v2 package is installed.

Screenshots or Response If applicable, add screenshots or response data to help explain your problem.

pfSense Version & Package Version:

Affected Endpoints:

n/a

Additional context Add any other context about the problem here.

mbentley commented 2 weeks ago

I tested all of the v2 versions and the error/warning doesn't happen on all versions from 2.2.0 to 2.1.3 but it does start with 2.2.0 and above.

jaredhendrickson13 commented 2 weeks ago

Thanks for reporting! I see the same behavior, but I don't see any significant difference between the output of v2.1.3 and v2.2.0 from the command it's complaining about /usr/local/sbin/pkg-static info -R --raw-format json-compact pfSense-pkg-\*. Running that command succeeds on both and only the size, directories and files have changed in the output; which is expected between builds: pkginfo-v213-v221.json

This will be a little hard to debug because pfSense-repoc is a compiled tool and the source for it does not appear to be open sourced. I'm sure it's looking for something specific in the output of that command, but it's not very apparent what that would be. I'll try to carve out some time this week to work backwards from v2.2.0 and see which commit specificaly introduced the issue.

jaredhendrickson13 commented 1 week ago

I believe I found the issue. pfSense-repoc only complains when a package contains more than a certain number of files. Maybe it's expecting the output of /usr/local/sbin/pkg-static info -R --raw-format json-compact pfSense-pkg-\* to be within some arbitrary character limit per package, I'm not completely sure. But that warning does go away when I make a build with less files, and it doesn't make a difference which files are cut.

For now, I can update the build process to exclude tests from the package in releases since those don't serve any functional purpose beyond development. That should give a little more wiggle room for a while. I'll need to find a better long term solution however.

mbentley commented 1 week ago

Oh interesting findings, thanks for digging into it further so quickly! That forum thread mentioned that they might have addressed what they called a cosmetic issue in a yet to be released patch (mentioned near the end of the thread) so maybe they addressed the limit, assuming that’s indeed it.