fix(lighthouse): show all models in selector even without default model (#9402)

Co-authored-by: Chandrapal Badshah <12944530+Chan9390@users.noreply.github.com>
Co-authored-by: Pepe Fagoaga <pepe@prowler.com>
This commit is contained in:
Chandrapal Badshah
2025-12-03 13:53:13 +05:30
committed by GitHub
parent 069f0d106c
commit f5c2146d19
2 changed files with 17 additions and 35 deletions
+11 -1
View File
@@ -2,7 +2,7 @@
All notable changes to the **Prowler UI** are documented in this file.
## [1.15.0] (Unreleased)
## [1.15.0] (Prowler Unreleased)
### 🚀 Added
@@ -13,6 +13,16 @@ All notable changes to the **Prowler UI** are documented in this file.
- Threat Map component to Overview Page [(#9324)](https://github.com/prowler-cloud/prowler/pull/9324)
- MongoDB Atlas provider support [(#9253)](https://github.com/prowler-cloud/prowler/pull/9253)
---
## [1.14.2] (Prowler v5.14.2)
### 🐞 Fixed
- Models list in Lighthouse selector when default model is not set for provider [(9402)](https://github.com/prowler-cloud/prowler/pull/9402)
---
## [1.14.0] (Prowler v5.14.0)
### 🚀 Added
+6 -34
View File
@@ -518,8 +518,8 @@ export const deleteLighthouseProviderByType = async (
};
/**
* Get lighthouse providers configuration with default models
* Returns only the default model for each provider to avoid loading hundreds of models
* Get lighthouse providers configuration with all available models
* Fetches all models for each provider to populate the model selector
*/
export const getLighthouseProvidersConfig = async () => {
try {
@@ -544,47 +544,19 @@ export const getLighthouseProvidersConfig = async () => {
(p: LighthouseProviderResource) => p.attributes?.is_active,
) || [];
// Build provider configuration with only default models
const providersConfig = await Promise.all(
activeProviders.map(async (provider: LighthouseProviderResource) => {
const providerType = provider.attributes
.provider_type as LighthouseProvider;
const defaultModelId = defaultModels[providerType];
// Fetch only the default model for this provider if it exists
let defaultModel = null;
if (defaultModelId) {
const headers = await getAuthHeaders({ contentType: false });
const url = new URL(`${apiBaseUrl}/lighthouse/models`);
url.searchParams.append("filter[provider_type]", providerType);
url.searchParams.append("filter[model_id]", defaultModelId);
try {
const response = await fetch(url.toString(), {
method: "GET",
headers,
});
const data = await response.json();
if (data.data && data.data.length > 0) {
defaultModel = {
id: data.data[0].attributes.model_id,
name:
data.data[0].attributes.model_name ||
data.data[0].attributes.model_id,
};
}
} catch (error) {
console.error(
`[Server] Error fetching default model for ${providerType}:`,
error,
);
}
}
// Fetch all models for this provider
const modelsResponse = await getLighthouseModelIds(providerType);
const models: ModelOption[] = modelsResponse.data || [];
return {
id: providerType,
name: PROVIDER_DISPLAY_NAMES[providerType],
models: defaultModel ? [defaultModel] : [],
models: models,
};
}),
);