Skip to content

Commit

Permalink
Fix endpoint validation issue with AI APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
RakhithaRR committed Oct 22, 2024
1 parent 4fd3ab6 commit 909759b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,6 @@
"Apis.Details.Endpoints.Security.api.key.header": "Authorization Header",
"Apis.Details.Endpoints.Security.api.key.query.param": "Authorization Query Param",
"Apis.Details.Endpoints.Security.api.key.value.placeholder": "Enter API Key",
"Apis.Details.Endpoints.Security.api.key.value.tooltip": "API Key for the AI API",
"Apis.Details.Endpoints.Security.api.key.value.value": "API Key",
"Apis.Details.Endpoints.Security.no.api.key.value.error": "API Key should not be empty",
"Apis.Details.Endpoints.SequenceBackend.AddCertificat": "Add Sequence Backend",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { isRestricted } from 'AppData/AuthManager';
import { FormattedMessage, useIntl } from 'react-intl';
import { Icon, TextField, Tooltip, InputAdornment, IconButton } from '@mui/material';
import { Icon, TextField, InputAdornment, IconButton } from '@mui/material';
import CONSTS from 'AppData/Constants';

export default function AIEndpointAuth(props) {
Expand Down Expand Up @@ -123,18 +123,6 @@ export default function AIEndpointAuth(props) {
InputProps={{
endAdornment: (
<InputAdornment position='end'>
<Tooltip
placement='top-start'
interactive
title={(
<FormattedMessage
id='Apis.Details.Endpoints.Security.api.key.value.tooltip'
defaultMessage='API Key for the AI API'
/>
)}
>
<Icon>security</Icon>
</Tooltip>
<IconButton onClick={handleToggleApiKeyVisibility} edge='end'>
<Icon>
{showApiKey ? 'visibility' : 'visibility_off'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,9 @@ function EndpointOverview(props) {
const endpointProp = 'production_endpoints';
if (endpointCategory[category]) {
delete endpointConfigCopy[endpointProp];
if (endpointConfigCopy?.endpoint_security?.production !== null) {
delete endpointConfigCopy.endpoint_security.production;
}
if (endpointConfigCopy.endpointType === 'failover') {
delete endpointConfigCopy.production_failovers;
}
Expand All @@ -423,6 +426,9 @@ function EndpointOverview(props) {
const endpointProp = 'sandbox_endpoints';
if (endpointCategory[category]) {
delete endpointConfigCopy[endpointProp];
if (endpointConfigCopy?.endpoint_security?.sandbox !== null) {
delete endpointConfigCopy.endpoint_security.sandbox;
}
if (endpointConfigCopy.endpointType === 'failover') {
delete endpointConfigCopy.sandbox_failovers;
}
Expand Down Expand Up @@ -1273,7 +1279,8 @@ function EndpointOverview(props) {
{toggleEndpointSecurityConfig}
apiId={api.id}
/>
{api.subtypeConfiguration?.subtype === 'AIAPI' && // eslint-disable-line
{endpointCategory.sandbox && // eslint-disable-line
api.subtypeConfiguration?.subtype === 'AIAPI' && // eslint-disable-line
(apiKeyParamConfig.authHeader || apiKeyParamConfig.authQueryParameter) && // eslint-disable-line
(<AIEndpointAuth
api={api}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ function Endpoints(props) {
case 'endpointSecurity': { // set endpoint security
const config = cloneDeep(initState.endpointConfig);
const tmpSecurityInfo = cloneDeep(value);
return { ...initState, endpointConfig: { ...config, endpoint_security: tmpSecurityInfo } };
return { ...initState, endpointConfig:
{ ...config, endpoint_security: { ...(config.endpoint_security || {}), ...tmpSecurityInfo } } };
}
case 'endpoint_type': { // set endpoint type
const config = getEndpointTemplateByType(
Expand Down

0 comments on commit 909759b

Please sign in to comment.