Skip to content

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

@codersaur

Description

@codersaur

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions