{"record":{"id":"fdf3919513e7b296","repo":"netbirdio/netbird","slug":"resource-not-part-of-network","errorCode":null,"errorMessage":"resource not part of network","messagePattern":"resource not part of network","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"management/server/networks/resources/manager.go","lineNumber":200,"sourceCode":"\treturn eventsToStore, snap, nil\n}\n\nfunc (m *managerImpl) GetResource(ctx context.Context, accountID, userID, networkID, resourceID string) (*types.NetworkResource, error) {\n\tok, ctx, err := m.permissionsManager.ValidateUserPermissions(ctx, accountID, userID, modules.Networks, operations.Read)\n\tif err != nil {\n\t\treturn nil, status.NewPermissionValidationError(err)\n\t}\n\tif !ok {\n\t\treturn nil, status.NewPermissionDeniedError()\n\t}\n\n\tresource, err := m.store.GetNetworkResourceByID(ctx, store.LockingStrengthNone, accountID, resourceID)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get network resource: %w\", err)\n\t}\n\n\tif resource.NetworkID != networkID {\n\t\treturn nil, errors.New(\"resource not part of network\")\n\t}\n\n\treturn resource, nil\n}\n\nfunc (m *managerImpl) UpdateResource(ctx context.Context, userID string, resource *types.NetworkResource) (*types.NetworkResource, error) {\n\tok, ctx, err := m.permissionsManager.ValidateUserPermissions(ctx, resource.AccountID, userID, modules.Networks, operations.Update)\n\tif err != nil {\n\t\treturn nil, status.NewPermissionValidationError(err)\n\t}\n\tif !ok {\n\t\treturn nil, status.NewPermissionDeniedError()\n\t}\n\n\tresourceType, domain, prefix, err := types.GetResourceType(resource.Address)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get resource type: %w\", err)\n\t}","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/management/server/networks/resources/manager.go#L182-L218","documentation":"Returned by managerImpl.GetResource: the resource was fetched by ID successfully, but its resource.NetworkID does not equal the networkID argument of the request. The API route is scoped to /networks/{networkId}/resources/{resourceId}, so this fires when the two IDs belong to different networks. It surfaces as a client error, not a store error.","triggerScenarios":"GET /api/networks/{networkA-id}/resources/{resource-of-networkB-id}; a stale resourceId captured before the network or resource was recreated; scripts iterating resources across networks while reusing a single networkID.","commonSituations":"A UI holding a cached resource ID after the network was recreated; copy-pasting IDs between environments; confusing the network-router resource ID with the network resource ID (similar path shapes).","solutions":["Call the list-resources endpoint of the specific network and use the IDs it returns, so resource and network always match.","Refresh cached IDs after networks or resources are recreated.","Double-check you are using a network resource ID, not a network router or route ID, in the path."],"exampleFix":"// before\nGET /api/networks/{networkA}/resources/{resB}\n// after\nGET /api/networks/{networkB}/resources/{resB} // resB belongs to networkB","handlingStrategy":"validation","validationCode":"// before GetResource: confirm the resource is listed under this network\nlist, err := m.GetNetworkResources(ctx, accountID, userID, networkID) // or the store list call\nfor _, r := range list {\n    if r.Id == resourceID { /* safe to call GetResource */ }\n}","typeGuard":null,"tryCatchPattern":"res, err := m.GetResource(ctx, accountID, userID, networkID, resourceID)\nif err != nil {\n    if err.Error() == \"resource not part of network\" {\n        // treat as not-found for this network: refresh IDs, do not blind-retry\n    }\n    return nil, err\n}","preventionTips":["Always obtain resource IDs by listing under the specific network, never from a global cache.","Invalidate cached IDs whenever networks or resources are recreated.","Treat this error as 404-equivalent in clients: refresh and re-navigate, never retry the same pair."],"tags":["networks","resources","management-api","validation"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}