Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building endpoints... Fatal error: Uncaught RESTAPI\Responses\ServerError: Cannot locate first Model object in a ModelSet with no Model objects #603

Closed
codersaur opened this issue Nov 16, 2024 · 2 comments · Fixed by #618

Comments

@codersaur
Copy link

Describe the bug
Package fails to build endpoints. It appears to fail enumerating my gateways and/or gatewaygroups.

To Reproduce
Install pfsense-api on pfSense CE with some gatewaygroups configured.

Expected behaviour

  1. Gateways and gateway groups are enumerated correctly.
  2. Failing that, if building endpoints fails to parse some object types it should fail gracefully and allow other endpoints to be built.

Screenshots or Response

    Fetching pfSense-2.7.2-pkg-RESTAPI.pkg: 100%  883 KiB 903.9kB/s    00:01
    Installing pfSense-pkg-RESTAPI-2.2_2...
    Extracting pfSense-pkg-RESTAPI-2.2_2: 100%
    Saving updated package information...
    done.
    Loading package configuration... done.
    Configuring package components...
    Loading package instructions...
    Custom commands...
    Menu items... done.
    Writing configuration... done.
    Building endpoints...
    Fatal error: Uncaught RESTAPI\Responses\ServerError: Cannot locate first Model object in a ModelSet with no Model objects in /usr/local/pkg/RESTAPI/Core/ModelSet.inc:68
    Stack trace:
    #0 /usr/local/pkg/RESTAPI/Models/RoutingGatewayGroup.inc(71): RESTAPI\Core\ModelSet->first()
    #1 /usr/local/pkg/RESTAPI/Core/Model.inc(911): RESTAPI\Models\RoutingGatewayGroup->from_internal_ipprotocol('unknown')
    #2 /usr/local/pkg/RESTAPI/Core/Model.inc(1860): RESTAPI\Core\Model->from_internal_object(Array)
    #3 /usr/local/pkg/RESTAPI/Fields/ForeignModelField.inc(310): RESTAPI\Core\Model::read_all()
    #4 /usr/local/pkg/RESTAPI/Fields/ForeignModelField.inc(329): RESTAPI\Fields\ForeignModelField->get_in_scope_models()
    #5 /usr/local/pkg/RESTAPI/Fields/ForeignModelField.inc(226): RESTAPI\Fields\ForeignModelField->__get_matches('name', 'Gateway_GB1_...')
    #6 /usr/local/pkg/RESTAPI/Core/Field.inc(905): RESTAPI\Fields\ForeignModelField->_from_internal('Gateway_GB1_...')
    #7 /usr/local/pkg/RESTAPI/Core/Model.inc(884): RESTAPI\Core\Field->from_internal('Gateway_GB1_...')
    #8 /usr/local/pkg/RESTAPI/Core/Model.inc(1860): RESTAPI\Core\Model->from_internal_object(Array)
    #9 /usr/local/pkg/RESTAPI/Models/DHCPServer.inc(262): RESTAPI\Core\Model::read_all()
    #10 /usr/local/pkg/RESTAPI/Models/DHCPServer.inc(249): RESTAPI\Models\DHCPServer->init_interfaces()
    #11 /usr/local/pkg/RESTAPI/Core/Endpoint.inc(369): RESTAPI\Models\DHCPServer->__construct(skip_init: true)
    #12 /usr/local/pkg/RESTAPI/Endpoints/ServicesDHCPServerEndpoint.inc(21): RESTAPI\Core\Endpoint->__construct()
    #13 /usr/local/pkg/RESTAPI/.resources/scripts/manage.php(40): RESTAPI\Endpoints\ServicesDHCPServerEndpoint->__construct()
    #14 /usr/local/pkg/RESTAPI/.resources/scripts/manage.php(430): build_endpoints()
    #15 {main}
      thrown in /usr/local/pkg/RESTAPI/Core/ModelSet.inc on line 68
    PHP ERROR: Type: 1, File: /usr/local/pkg/RESTAPI/Core/ModelSet.inc, Line: 68, Message: Uncaught RESTAPI\Responses\ServerError: Cannot locate first Model object in a ModelSet with no Model objects in /usr/local/pkg/RESTAPI/Core/ModelSet.inc:68
    Stack trace:
    #0 /usr/local/pkg/RESTAPI/Models/RoutingGatewayGroup.inc(71): RESTAPI\Core\ModelSet->first()
    #1 /usr/local/pkg/RESTAPI/Core/Model.inc(911): RESTAPI\Models\RoutingGatewayGroup->from_internal_ipprotocol('unknown')
    #2 /usr/local/pkg/RESTAPI/Core/Model.inc(1860): RESTAPI\Core\Model->from_internal_object(Array)
    #3 /usr/local/pkg/RESTAPI/Fields/ForeignModelField.inc(310): RESTAPI\Core\Model::read_all()
    #4 /usr/local/pkg/RESTAPI/Fields/ForeignModelField.inc(329): RESTAPI\Fields\ForeignModelField->get_in_scope_models()
    #5 /usr/local/pkg/RESTAPI/Fields/ForeignModelField.inc(226): RESTAPI\Fields\ForeignModelField->__get_matches('name', 'Gateway_GB1_...')
    #6 /usr/local/pkg/RESTAPI/Core/Field.inc(905): RESTAPI\Fields\ForeignModelField->_from_internal('Gateway_GB1_...')
    #7 /usr/local/pkg/RESTAPI/Core/Model.inc(884): RESTAPI\Core\Field->from_internal('Gateway_GB1_...')
    #8 /usr/local/pkg/RESTAPI/Core/Model.inc(1860): RESTAPI\Core\Model->from_internal_object(Array)
    #9 /usr/local/pkg/RESTAPI/Models/DHCPServer.inc(262): RESTAPI\Core\Model::read_all()
    #10 /usr/local/pkg/RESTAPI/Models/DHCPServer.inc(249): RESTAPI\Models\DHCPServer->init_interfaces()
    #11 /usr/local/pkg/RESTAPI/Core/Endpoint.inc(369): RESTAPI\Models\DHCPServer->__construct(skip_init: true)
    #12 /usr/local/pkg/RESTAPI/Endpoints/ServicesDHCPServerEndpoint.inc(21): RESTAPI\Core\Endpoint->__construct()
    #13 /usr/local/pkg/RESTAPI/.resources/scripts/manage.php(40): RESTAPI\Endpoints\ServicesDHCPServerEndpoint->__construct()
    #14 /usr/local/pkg/RESTAPI/.resources/scripts/manage.php(430): build_endpoints()
    #15 {main}
      thrownBuilding forms... done.
    Building privileges...
    Fatal error: Uncaught RESTAPI\Responses\ServerError: Cannot locate first Model object in a ModelSet with no Model objects in /usr/local/pkg/RESTAPI/Core/ModelSet.inc:68
    Stack trace:
    #0 /usr/local/pkg/RESTAPI/Models/RoutingGatewayGroup.inc(71): RESTAPI\Core\ModelSet->first()
    #1 /usr/local/pkg/RESTAPI/Core/Model.inc(911): RESTAPI\Models\RoutingGatewayGroup->from_internal_ipprotocol('unknown')
    #2 /usr/local/pkg/RESTAPI/Core/Model.inc(1860): RESTAPI\Core\Model->from_internal_object(Array)
    #3 /usr/local/pkg/RESTAPI/Fields/ForeignModelField.inc(310): RESTAPI\Core\Model::read_all()
    #4 /usr/local/pkg/RESTAPI/Fields/ForeignModelField.inc(329): RESTAPI\Fields\ForeignModelField->get_in_scope_models()
    #5 /usr/local/pkg/RESTAPI/Fields/ForeignModelField.inc(226): RESTAPI\Fields\ForeignModelField->__get_matches('name', 'Gateway_GB1_...')
    #6 /usr/local/pkg/RESTAPI/Core/Field.inc(905): RESTAPI\Fields\ForeignModelField->_from_internal('Gateway_GB1_...')
    #7 /usr/local/pkg/RESTAPI/Core/Model.inc(884): RESTAPI\Core\Field->from_internal('Gateway_GB1_...')
    #8 /usr/local/pkg/RESTAPI/Core/Model.inc(1860): RESTAPI\Core\Model->from_internal_object(Array)
    #9 /usr/local/pkg/RESTAPI/Models/DHCPServer.inc(262): RESTAPI\Core\Model::read_all()
    #10 /usr/local/pkg/RESTAPI/Models/DHCPServer.inc(249): RESTAPI\Models\DHCPServer->init_interfaces()
    #11 /usr/local/pkg/RESTAPI/Core/Endpoint.inc(369): RESTAPI\Models\DHCPServer->__construct(skip_init: true)
    #12 /usr/local/pkg/RESTAPI/Endpoints/ServicesDHCPServerEndpoint.inc(21): RESTAPI\Core\Endpoint->__construct()
    #13 /usr/local/pkg/RESTAPI/Caches/PrivilegesCache.inc(24): RESTAPI\Endpoints\ServicesDHCPServerEndpoint->__construct()
    #14 /usr/local/pkg/RESTAPI/Core/Cache.inc(68): RESTAPI\Caches\PrivilegesCache->get_data_to_cache()
    #15 /usr/local/pkg/RESTAPI/.resources/scripts/manage.php(94): RESTAPI\Core\Cache->process()
    #16 /usr/local/pkg/RESTAPI/.resources/scripts/manage.php(82): build_privs()
    #17 /usr/local/pkg/RESTAPI/.resources/scripts/manage.php(426): build_forms()
    #18 {main}
      thrown in /usr/local/pkg/RESTAPI/Core/ModelSet.inc on line 68
    PHP ERROR: Type: 1, File: /usr/local/pkg/RESTAPI/Core/ModelSet.inc, Line: 68, Message: Uncaught RESTAPI\Responses\ServerError: Cannot locate first Model object in a ModelSet with no Model objects in /usr/local/pkg/RESTAPI/Core/ModelSet.inc:68
    Stack trace:
    #0 /usr/local/pkg/RESTAPI/Models/RoutingGatewayGroup.inc(71): RESTAPI\Core\ModelSet->first()
    #1 /usr/local/pkg/RESTAPI/Core/Model.inc(911): RESTAPI\Models\RoutingGatewayGroup->from_internal_ipprotocol('unknown')
    #2 /usr/local/pkg/RESTAPI/Core/Model.inc(1860): RESTAPI\Core\Model->from_internal_object(Array)
    #3 /usr/local/pkg/RESTAPI/Fields/ForeignModelField.inc(310): RESTAPI\Core\Model::read_all()
    #4 /usr/local/pkg/RESTAPI/Fields/ForeignModelField.inc(329): RESTAPI\Fields\ForeignModelField->get_in_scope_models()
    #5 /usr/local/pkg/RESTAPI/Fields/ForeignModelField.inc(226): RESTAPI\Fields\ForeignModelField->__get_matches('name', 'Gateway_GB1_...')
    #6 /usr/local/pkg/RESTAPI/Core/Field.inc(905): RESTAPI\Fields\ForeignModelField->_from_internal('Gateway_GB1_...')
    #7 /usr/local/pkg/RESTAPI/Core/Model.inc(884): RESTAPI\Core\Field->from_internal('Gateway_GB1_...')
    #8 /usr/local/pkg/RESTAPI/Core/Model.inc(1860): RESTAPI\Core\Model->from_internal_object(Array)
    #9 /usr/local/pkg/RESTAPI/Models/DHCPServer.inc(262): RESTAPI\Core\Model::read_all()
    #10 /usr/local/pkg/RESTAPI/Models/DHCPServer.inc(249): RESTAPI\Models\DHCPServer->init_interfaces()
    #11 /usr/local/pkg/RESTAPI/Core/Endpoint.inc(369): RESTAPI\Models\DHCPServer->__construct(skip_init: true)
    #12 /usr/local/pkg/RESTAPI/Endpoints/ServicesDHCPServerEndpoint.inc(21): RESTAPI\Core\Endpoint->__construct()
    #13 /usr/local/pkg/RESTAPI/Caches/PrivilegesCache.inc(24): RESTAPI\Endpoints\ServicesDHCPServerEndpoint->__construct()
    #14 /usr/local/pkg/RESTAPI/Core/Cache.inc(68): RESTAPI\Caches\PrivilegesCache->get_data_to_cache()
    #15 /usr/local/pkg/RESTAPI/.resources/scripts/manage.php(94): RESTAPI\Core\Cache->process()
    #16 /usr/local/pkg/RESTAPI/.resources/scripts/manage.php(82): build_privs()
    #17 /usr/local/pkg/RESTAPI/.resources/scripts/manage.php(426): build_forms()
    #18 {main}
      thrownGenerating schema files for \RESTAPI\Schemas\GraphQLSchema...
    Fatal error: Uncaught RESTAPI\Responses\ServerError: Cannot locate first Model object in a ModelSet with no Model objects in /usr/local/pkg/RESTAPI/Core/ModelSet.inc:68
    Stack trace:
    #0 /usr/local/pkg/RESTAPI/Models/RoutingGatewayGroup.inc(71): RESTAPI\Core\ModelSet->first()
    #1 /usr/local/pkg/RESTAPI/Core/Model.inc(911): RESTAPI\Models\RoutingGatewayGroup->from_internal_ipprotocol('unknown')
    #2 /usr/local/pkg/RESTAPI/Core/Model.inc(1860): RESTAPI\Core\Model->from_internal_object(Array)
    #3 /usr/local/pkg/RESTAPI/Fields/ForeignModelField.inc(310): RESTAPI\Core\Model::read_all()
    #4 /usr/local/pkg/RESTAPI/Fields/ForeignModelField.inc(329): RESTAPI\Fields\ForeignModelField->get_in_scope_models()
    #5 /usr/local/pkg/RESTAPI/Fields/ForeignModelField.inc(226): RESTAPI\Fields\ForeignModelField->__get_matches('name', 'Gateway_GB1_...')
    #6 /usr/local/pkg/RESTAPI/Core/Field.inc(905): RESTAPI\Fields\ForeignModelField->_from_internal('Gateway_GB1_...')
    #7 /usr/local/pkg/RESTAPI/Core/Model.inc(884): RESTAPI\Core\Field->from_internal('Gateway_GB1_...')
    #8 /usr/local/pkg/RESTAPI/Core/Model.inc(1860): RESTAPI\Core\Model->from_internal_object(Array)
    #9 /usr/local/pkg/RESTAPI/Models/DHCPServer.inc(262): RESTAPI\Core\Model::read_all()
    #10 /usr/local/pkg/RESTAPI/Models/DHCPServer.inc(249): RESTAPI\Models\DHCPServer->init_interfaces()
    #11 /usr/local/pkg/RESTAPI/Core/Endpoint.inc(369): RESTAPI\Models\DHCPServer->__construct(skip_init: true)
    #12 /usr/local/pkg/RESTAPI/Endpoints/ServicesDHCPServerEndpoint.inc(21): RESTAPI\Core\Endpoint->__construct()
    #13 /usr/local/pkg/RESTAPI/Schemas/GraphQLSchema.inc(346): RESTAPI\Endpoints\ServicesDHCPServerEndpoint->__construct()
    #14 /usr/local/pkg/RESTAPI/Schemas/GraphQLSchema.inc(78): RESTAPI\Schemas\GraphQLSchema->get_endpoint_query_types()
    #15 /usr/local/pkg/RESTAPI/Schemas/GraphQLSchema.inc(92): RESTAPI\Schemas\GraphQLSchema->get_schema()
    #16 /usr/local/pkg/RESTAPI/Core/Schema.inc(74): RESTAPI\Schemas\GraphQLSchema->get_schema_str()
    #17 /usr/local/pkg/RESTAPI/.resources/scripts/manage.php(111): RESTAPI\Core\Schema->save_schema()
    #18 /usr/local/pkg/RESTAPI/.resources/scripts/manage.php(438): build_schemas()
    #19 {main}
      thrown in /usr/local/pkg/RESTAPI/Core/ModelSet.inc on line 68
    PHP ERROR: Type: 1, File: /usr/local/pkg/RESTAPI/Core/ModelSet.inc, Line: 68, Message: Uncaught RESTAPI\Responses\ServerError: Cannot locate first Model object in a ModelSet with no Model objects in /usr/local/pkg/RESTAPI/Core/ModelSet.inc:68
    Stack trace:
    #0 /usr/local/pkg/RESTAPI/Models/RoutingGatewayGroup.inc(71): RESTAPI\Core\ModelSet->first()
    #1 /usr/local/pkg/RESTAPI/Core/Model.inc(911): RESTAPI\Models\RoutingGatewayGroup->from_internal_ipprotocol('unknown')
    #2 /usr/local/pkg/RESTAPI/Core/Model.inc(1860): RESTAPI\Core\Model->from_internal_object(Array)
    #3 /usr/local/pkg/RESTAPI/Fields/ForeignModelField.inc(310): RESTAPI\Core\Model::read_all()
    #4 /usr/local/pkg/RESTAPI/Fields/ForeignModelField.inc(329): RESTAPI\Fields\ForeignModelField->get_in_scope_models()
    #5 /usr/local/pkg/RESTAPI/Fields/ForeignModelField.inc(226): RESTAPI\Fields\ForeignModelField->__get_matches('name', 'Gateway_GB1_...')
    #6 /usr/local/pkg/RESTAPI/Core/Field.inc(905): RESTAPI\Fields\ForeignModelField->_from_internal('Gateway_GB1_...')
    #7 /usr/local/pkg/RESTAPI/Core/Model.inc(884): RESTAPI\Core\Field->from_internal('Gateway_GB1_...')
    #8 /usr/local/pkg/RESTAPI/Core/Model.inc(1860): RESTAPI\Core\Model->from_internal_object(Array)
    #9 /usr/local/pkg/RESTAPI/Models/DHCPServer.inc(262): RESTAPI\Core\Model::read_all()
    #10 /usr/local/pkg/RESTAPI/Models/DHCPServer.inc(249): RESTAPI\Models\DHCPServer->init_interfaces()
    #11 /usr/local/pkg/RESTAPI/Core/Endpoint.inc(369): RESTAPI\Models\DHCPServer->__construct(skip_init: true)
    #12 /usr/local/pkg/RESTAPI/Endpoints/ServicesDHCPServerEndpoint.inc(21): RESTAPI\Core\Endpoint->__construct()
    #13 /usr/local/pkg/RESTAPI/Schemas/GraphQLSchema.inc(346): RESTAPI\Endpoints\ServicesDHCPServerEndpoint->__construct()
    #14 /usr/local/pkg/RESTAPI/Schemas/GraphQLSchema.inc(78): RESTAPI\Schemas\GraphQLSchema->get_endpoint_query_types()
    #15 /usr/local/pkg/RESTAPI/Schemas/GraphQLSchema.inc(92): RESTAPI\Schemas\GraphQLSchema->get_schema()
    #16 /usr/local/pkg/RESTAPI/Core/Schema.inc(74): RESTAPI\Schemas\GraphQLSchema->get_schema_str()
    #17 /usr/local/pkg/RESTAPI/.resources/scripts/manage.php(111): RESTAPI\Core\Schema->save_schema()
    #18 /usr/local/pkg/RESTAPI/.resources/scripts/manage.php(438): build_schemas()
    #19 {main}
      thrownRestoring REST API configuration... no backup found.
    Starting REST API settings sync... not configured.
    Configuring schedule for \RESTAPI\Caches\AvailablePackageCache... done.
    Configuring schedule for \RESTAPI\Caches\RESTAPIVersionReleasesCache... done.
    Initiating webConfigurator restart... done.

pfSense Version & Package Version:

  • pfSense Version: 2.7.2-RELEASE (amd64)
  • Package Version: 2.x (I've tried latest and various other 2.x versions)

Affected Endpoints:
All (unable to build any).

Additional context
Add any other context about the problem here.

@jaredhendrickson13
Copy link
Owner

I've seen this occur before on some builtin/pfSense generated gateways that do not correctly set an ipprotocol in config, or the default WAN_DHCP gateway is not saved in config at all. Usually saving those gateways again in the UI fixes it. Can you provide your current gateways section of your config?

@codersaur
Copy link
Author

Thanks, refreshing all the gateways in the Web UI seems to have fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants