fix logger import
This commit is contained in:
@@ -36,6 +36,47 @@
|
||||
getValidationPolicies(),
|
||||
getEnvironments()
|
||||
]);
|
||||
|
||||
const policyArray = Array.isArray(policiesData) ? policiesData : [];
|
||||
const environmentArray = Array.isArray(envsData) ? envsData : [];
|
||||
|
||||
const invalidPolicies = policyArray
|
||||
.map((policy, index) => ({ index, policy }))
|
||||
.filter(({ policy }) => !policy || typeof policy !== 'object');
|
||||
const policiesWithMissingName = policyArray
|
||||
.map((policy, index) => ({ index, policy }))
|
||||
.filter(({ policy }) => policy && (policy.name === null || policy.name === undefined));
|
||||
|
||||
const invalidEnvironments = environmentArray
|
||||
.map((env, index) => ({ index, env }))
|
||||
.filter(({ env }) => !env || typeof env !== 'object');
|
||||
const environmentsWithMissingName = environmentArray
|
||||
.map((env, index) => ({ index, env }))
|
||||
.filter(({ env }) => env && (env.name === null || env.name === undefined));
|
||||
|
||||
console.log('[AutomationSettingsPage][Debug] Loaded payload shapes', {
|
||||
policiesCount: policyArray.length,
|
||||
environmentsCount: environmentArray.length,
|
||||
invalidPoliciesCount: invalidPolicies.length,
|
||||
policiesWithMissingNameCount: policiesWithMissingName.length,
|
||||
invalidEnvironmentsCount: invalidEnvironments.length,
|
||||
environmentsWithMissingNameCount: environmentsWithMissingName.length
|
||||
});
|
||||
|
||||
if (invalidPolicies.length > 0 || policiesWithMissingName.length > 0) {
|
||||
console.warn('[AutomationSettingsPage][Debug] Suspicious policy payload detected', {
|
||||
invalidPolicies,
|
||||
policiesWithMissingName
|
||||
});
|
||||
}
|
||||
|
||||
if (invalidEnvironments.length > 0 || environmentsWithMissingName.length > 0) {
|
||||
console.warn('[AutomationSettingsPage][Debug] Suspicious environments payload detected', {
|
||||
invalidEnvironments,
|
||||
environmentsWithMissingName
|
||||
});
|
||||
}
|
||||
|
||||
policies = policiesData;
|
||||
environments = envsData;
|
||||
} catch (error) {
|
||||
@@ -51,6 +92,16 @@
|
||||
}
|
||||
|
||||
function handleEdit(policy) {
|
||||
if (!policy) {
|
||||
console.error('[AutomationSettingsPage][Debug] handleEdit received invalid policy', { policy });
|
||||
return;
|
||||
}
|
||||
console.log('[AutomationSettingsPage][Debug] handleEdit policy snapshot', {
|
||||
id: policy.id,
|
||||
name: policy.name,
|
||||
environment_id: policy.environment_id,
|
||||
dashboard_ids_type: Array.isArray(policy.dashboard_ids) ? 'array' : typeof policy.dashboard_ids
|
||||
});
|
||||
selectedPolicy = policy;
|
||||
showForm = true;
|
||||
}
|
||||
@@ -83,10 +134,40 @@
|
||||
}
|
||||
|
||||
function getEnvName(id) {
|
||||
return environments.find(e => e.id === id)?.name || id;
|
||||
const envMatch = environments.find((e) => e?.id === id);
|
||||
if (!envMatch) {
|
||||
console.warn('[AutomationSettingsPage][Debug] Environment not found for policy environment_id', {
|
||||
requestedEnvironmentId: id,
|
||||
environmentsCount: Array.isArray(environments) ? environments.length : -1
|
||||
});
|
||||
} else if (envMatch.name === null || envMatch.name === undefined) {
|
||||
console.warn('[AutomationSettingsPage][Debug] Environment has null/undefined name', {
|
||||
requestedEnvironmentId: id,
|
||||
environment: envMatch
|
||||
});
|
||||
}
|
||||
return envMatch?.name || id;
|
||||
}
|
||||
|
||||
const dayLabels = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
||||
|
||||
$effect(() => {
|
||||
if (isLoading) return;
|
||||
|
||||
const policiesWithNullName = (Array.isArray(policies) ? policies : []).filter(
|
||||
(policy) => policy && (policy.name === null || policy.name === undefined)
|
||||
);
|
||||
const policyEntriesWithNullDashboardIds = (Array.isArray(policies) ? policies : []).filter(
|
||||
(policy) => policy && !Array.isArray(policy.dashboard_ids)
|
||||
);
|
||||
|
||||
if (policiesWithNullName.length > 0 || policyEntriesWithNullDashboardIds.length > 0) {
|
||||
console.warn('[AutomationSettingsPage][Debug] Render-time suspicious policy data detected', {
|
||||
policiesWithNullName,
|
||||
policyEntriesWithNullDashboardIds
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="container mx-auto p-6 max-w-5xl">
|
||||
|
||||
Reference in New Issue
Block a user