Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure getInstallProperties always returns a value #3363

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ export async function getInstallProperties() {
data = await get(uri);
} catch (error) {
if (error?.response?.status === 404) {
// eslint-disable-next-line no-console
console.warn(
'Install properties not found, setting client-mode defaults'
);
data = {
dashboardNamespace: 'N/A',
dashboardVersion: 'kubectl-proxy-client',
Expand All @@ -116,6 +120,13 @@ export async function getInstallProperties() {
triggersNamespace: 'Unknown',
triggersVersion: 'Unknown'
};
} else {
// eslint-disable-next-line no-console
console.error(
'Failed loading install properties, setting read-only default',
error
);
data = { isReadOnly: true };
}
}
return data;
Expand Down
2 changes: 1 addition & 1 deletion src/api/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ describe('getInstallProperties', () => {
http.get(/\/properties$/, () => new HttpResponse(null, { status: 500 }))
);
const properties = await API.getInstallProperties();
expect(properties).toBeUndefined();
expect(properties).toEqual({ isReadOnly: true });
});
});

Expand Down
Loading