jaredhendrickson13 / pfsense-api

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

Version 2 Installed Failed on pfsense 3100 with PHP Error - Crashed WebUI - Server 500 Error #502

Closed war59312 closed 2 months ago

war59312 commented 3 months ago

Describe the bug Attempted install of v2 on my pfsense 3100. Already had working v1.

To Reproduce Steps to reproduce the behavior:

  1. pkg-static -C /dev/null add https://github.com/jaredhendrickson13/pfsense-api/releases/download/v2.0.0/pfSense-24.03-pkg-RESTAPI.pkg

pfsense then craashes:

The web server encountered an error processing this request. 50x error

Expected behavior Install cleanly without crashing

Response

Fetching pfSense-24.03-pkg-RESTAPI.pkg: ....... done
Installing pfSense-pkg-RESTAPI-2.0...
Extracting pfSense-pkg-RESTAPI-2.0: .......... done
Saving updated package information...
done.
Loading package configuration... done.
Configuring package components...
Loading package instructions...
Custom commands...
Menu items... done.
Writing configuration... done.
<pre style="white-space: pre-wrap;">PHP ERROR: Type: 64, File: /usr/local/pkg/RESTAPI/Validators/NumericRangeValidator.inc, Line: 23, Message: Cannot use float as default value for parameter $maximum of type int</pre><pre style="white-space: pre-wrap;">PHP ERROR: Type: 64, File: /usr/local/pkg/RESTAPI/Validators/NumericRangeValidator.inc, Line: 23, Message: Cannot use float as default value for parameter $maximum of type int</pre><pre style="white-space: pre-wrap;">PHP ERROR: Type: 64, File: /usr/local/pkg/RESTAPI/Validators/NumericRangeValidator.inc, Line: 23, Message: Cannot use float as default value for parameter $maximum of type int</pre><pre style="white-space: pre-wrap;">PHP ERROR: Type: 64, File: /usr/local/pkg/RESTAPI/Validators/NumericRangeValidator.inc, Line: 23, Message: Cannot use float as default value for parameter $maximum of type int</pre><pre style="white-space: pre-wrap;">PHP ERROR: Type: 64, File: /usr/local/pkg/RESTAPI/Validators/NumericRangeValidator.inc, Line: 23, Message: Cannot use float as default value for parameter $maximum of type int</pre><pre style="white-space: pre-wrap;">PHP ERROR: Type: 64, File: /usr/local/pkg/RESTAPI/Validators/NumericRangeValidator.inc, Line: 23, Message: Cannot use float as default value for parameter $maximum of type int</pre>pkg-static: POST-INSTALL script failed

pfSense Version & Package Version:

Sadly webui is now hard down.

Tried via SSH:

11 Restart GUI 16 Restart PHP-FPN 15 Restore recent configuration

Sadly GUI is still down with 500 error.

Tried to remove via SSH but stil 500 error and remove failed too:

[24.03-RELEASE][admin@pfSense.localdomain]/root: pfsense-restapi delete
<pre style="white-space: pre-wrap;">PHP ERROR: Type: 64, File: /usr/local/pkg/RESTAPI/Validators/NumericRangeValidator.inc, Line: 23, Message: Cannot use float as default value for parameter $maximum of type int</pre>[24.03-RELEASE][admin@pfSense.localdomain]/root:

Alright managed to get webui back up and removed the package for now. See it removed both v1 and v2.

[24.03-RELEASE][admin@pfSense.localdomain]/root: pfsense-restapi delete
<pre style="white-space: pre-wrap;">PHP ERROR: Type: 64, File: /usr/local/pkg/RESTAPI/Validators/NumericRangeValidator.inc, Line: 23, Message: Cannot use float as default value for parameter $maximum of type int</pre>[24.03-RELEASE][admin@pfSense.localdomain]/root: pfsense-restapi delete
<pre style="white-space: pre-wrap;">PHP ERROR: Type: 64, File: /usr/local/pkg/RESTAPI/Validators/NumericRangeValidator.inc, Line: 23, Message: Cannot use float as default value for parameter $maximum of type int</pre>[24.03-RELEASE][admin@pfSense.localdomain]/root: rm /usr/local/pkg/RESTAPI/Validators/NumericRangeValidator.inc
[24.03-RELEASE][admin@pfSense.localdomain]/root: pfsense-restapi delete
<pre style="white-space: pre-wrap;">PHP ERROR: Type: 64, File: /usr/local/pkg/RESTAPI/Fields/FloatField.inc, Line: 69, Message: Cannot use float as default value for parameter $maximum of type int</pre>[24.03-RELEASE][admin@pfSense.localdomain]/root: rm /usr/local/pkg/RESTAPI/Fields/FloatField.inc
[24.03-RELEASE][admin@pfSense.localdomain]/root: pfsense-restapi delete
<pre style="white-space: pre-wrap;">PHP ERROR: Type: 64, File: /usr/local/pkg/RESTAPI/Fields/IntegerField.inc, Line: 70, Message: Cannot use float as default value for parameter $maximum of type int</pre>[24.03-RELEASE][admin@pfSense.localdomain]/root: rm /usr/local/pkg/RESTAPI/Fields/IntegerField.inc,
rm: /usr/local/pkg/RESTAPI/Fields/IntegerField.inc,: No such file or directory
[24.03-RELEASE][admin@pfSense.localdomain]/root: rm /usr/local/pkg/RESTAPI/Fields/IntegerField.inc
[24.03-RELEASE][admin@pfSense.localdomain]/root: pfsense-restapi delete
<pre style="white-space: pre-wrap;">PHP ERROR: Type: 64, File: /usr/local/pkg/RESTAPI/Fields/UnixTimeField.inc, Line: 74, Message: Cannot use float as default value for parameter $maximum of type int</pre>[24.03-RELEASE][admin@pfSense.localdomain]/root: rm /usr/local/pkg/RESTAPI/Fields/UnixTimeField.inc
[24.03-RELEASE][admin@pfSense.localdomain]/root: pfsense-restapi delete
pfSense-pkg-RESTAPI-2.0: missing file /usr/local/pkg/RESTAPI/Fields/FloatField.inc
pfSense-pkg-RESTAPI-2.0: missing file /usr/local/pkg/RESTAPI/Fields/IntegerField.inc
pfSense-pkg-RESTAPI-2.0: missing file /usr/local/pkg/RESTAPI/Fields/UnixTimeField.inc
pfSense-pkg-RESTAPI-2.0: missing file /usr/local/pkg/RESTAPI/Validators/NumericRangeValidator.inc
pfSense-pkg-RESTAPI-2.0: missing file /usr/local/www/api/v2/documentation/index.php
pfSense-pkg-RESTAPI-2.0: missing file /usr/local/www/api/v2/schema/index.php
pkg-static: unlinkat(usr/local/www/api/v2/schema/): No such file or directory
pkg-static: unlinkat(usr/local/www/api/v2/): No such file or directory
pkg-static: unlinkat(usr/local/www/api/v2/documentation/): No such file or directory
pkg-static: unlinkat(usr/local/www/api/v2/): No such file or directory
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):

Installed packages to be REMOVED:
        pfSense-pkg-RESTAPI: 2.0

Number of packages to be removed: 1

The operation will free 6 MiB.
[1/1] Deinstalling pfSense-pkg-RESTAPI-2.0...
The RESTAPI package is not installed.

Deletion aborted.[1/1] Deleting files for pfSense-pkg-RESTAPI-2.0: ...
[1/1] Deleting files for pfSense-pkg-RESTAPI-2.0...
[1/1] Deleting files for pfSense-pkg-RESTAPI-2.0....
[1/1] Deleting files for pfSense-pkg-RESTAPI-2.0........
[1/1] Deleting files for pfSense-pkg-RESTAPI-2.0...
[1/1] Deleting files for pfSense-pkg-RESTAPI-2.0...
[1/1] Deleting files for pfSense-pkg-RESTAPI-2.0... done
Restarting webConfigurator... done.
jaredhendrickson13 commented 3 months ago

This doesn't seem to occur when installing on an amd64 build of pfSense Plus 24.03 (which is what the package was tested on). Both v1 and v2 install and operate normally. I believe the 3100 has a 32-bit CPU which may not be able to handle some of the larger integers used in the package. To confirm, can you run uname -a from the pfSense command line?

war59312 commented 3 months ago

You are correct, has a 32bit ARM CPU.

[24.03-RELEASE][admin@pfSense.localdomain]/root: uname -a
FreeBSD pfSense.localdomain 15.0-CURRENT FreeBSD 15.0-CURRENT #1 plus-RELENG_24_03-n256311-e71f834dd81: Fri Apr 19 00:24:55 UTC 2024     root@freebsd:/var/jenkins/workspace/pfSense-Plus-snapshots-24_03-main/obj/armv7/07ElPskS/var/jenkins/workspace/pfSense-Plus-snapshots-24_03-main/sources/FreeBSD-src-plus-RELENG_24_03/arm.armv7/sys/pfSense-3100 arm

Friendly suggestion, if not planning to support 32bit arm for version 2, then recommend stating so in the README and tell users to use version 1 instead.

And put a check in the version 2 package that first verifies not running on 32bit and if it is, stop and give an error.

jaredhendrickson13 commented 3 months ago

I was under the impression that 24.03 would not support 32-bit ARM since it was based on FreeBSD 15 (https://forum.netgate.com/topic/183472/3100-will-reach-end-of-life-in-5-days/6) so it was not considered during development. That was an error on my part.

Friendly suggestion, if not planning to support 32bit arm for version 2, then recommend stating so in the README and tell users to use version 1 instead.

And put a check in the version 2 package that first verifies not running on 32-bit and if it is, stop and give an error.

Short term, I will add some safety checks for this in the next patch and add a warning in the documentation specifically about 32-bit support, there is a general 'Not tested on anything but amd64' warning but I agree this probably warrants more.

Long term, I'm not opposed to making changes to allow the package to install cleanly on 32-bit systems assuming there's enough demand for it and there are enough Netgate 3100 users willing to test it out.


I'll also leave some instructions here in case anybody else runs into this issue or an issue similar where the package can't be removed via pfsense-restapi delete:

If that doesn't remove the package, you can try the following:

war59312 commented 3 months ago

Sounds good. Much appreciated.

Yea the FeeBSD team decided to keep a little 32bit support going for now. :)

Per https://lists.freebsd.org/archives/freebsd-announce/2024-February/000117.html

FreeBSD is deprecating 32-bit platforms over the next couple of major releases. We anticipate FreeBSD 15.0 will not include the armv6, i386, and powerpc platforms, and FreeBSD 16.0 will not include armv7. Support for executing 32-bit binaries on 64-bit kernels will be retained through at least the lifetime of the stable/16 branch if not longer. (There is currently no plan to remove support for 32-bit binaries on 64-bit kernels.)

The pfsense 3100 is armv7 so good for now at least.