Closed ikethecoder closed 2 years ago
In the logs, I get this, but no other details:
TypeError: Cannot read property 'id' of null
at /app/dist/www/server/pages/devportal/access.js:2582:145
at arrayAggregator (/app/node_modules/lodash/_arrayAggregator.js:17:32)
at /app/node_modules/lodash/_createAggregator.js:19:12
at AccessList (/app/dist/www/server/pages/devportal/access.js:2579:41)
I think the issue is that there are ServiceAccess records with no ProductEnvironment, which in theory should not happen.
Why would there be records for:
select * from "ServiceAccess" where "productEnvironment" is null;
Well, records can exist if a user has used "Link Consumer to Namespace" or the Consumer was migrated during initial onboarding from the Gateway; in these cases, there is no Application or ProductEnvironment linked.
This might be a duplicate of #148, where I have added some filtering for if these sneak by the API.
Root cause is that it is possible to get orphaned Environments (Environments that are not associated with any Products). This can occur when Products and Environments are updated via the Directory API.
This ticket will cleanup the orphaned records:
select * from "Environment" where product is null;
select * from "GatewayService" where "environment" in (select id from "Environment" where product is null);
update "GatewayService" set environment = null where "environment" in (select id from "Environment" where product is null);
delete from "Environment" where product is null;
And will fix the Directory API (Batch Feeder) to avoid such issues in the future.
There should never be a case where an Environment is not associated with a Product.
This error can also occur when an Environment is deleted. In this case, existing ServiceAccess records get there productEnvironment
attribute set to null
.
When I log in with my Github account and go to My Access in Test environment, I get this page: