Open shahargl opened 2 months ago
/bounty 20
/attempt #1327
with your implementation plan/claim #1327
in the PR body to claim the bountyThank you for contributing to keephq/keep!
Add a bounty • Share on socials
Attempt | Started (GMT+0) | Solution |
---|---|---|
🔴 @OlegPlichko | Jul 8, 2024, 2:46:48 PM | WIP |
🔴 @ydv129 | Jul 10, 2024, 2:27:44 PM | WIP |
🔴 @Anshgrover23 | Jul 21, 2024, 8:57:56 AM | WIP |
🟢 @Apoorv012 | Jul 23, 2024, 7:07:04 PM | WIP |
/attempt #1327
I have some questions:
- for urls with/without "/" in the end
is "/" at the end mandatory?
- URL's - http, https, http://, localhost, port numbers, etc
is http or https mandatory?
- host vs url
waht does it mean?
this should be enforced both on frontend (for quickly tell the user what's wrong) and backend (enforcements)
what enforcements means here? should something like auto correction be implemented on backend, ex: localhost -> http://localhost/
part of the task is to figure that out, we don't have all the answers for that. currently, every provider defines its own configuration primitives which prune to bugs.
/bounty 0
/attempt #1327
Here are some steps and pointers to help you get started on resolving this issue:
Define Validation Schemas:
Yup
or Joi
for schema validation.Update Frontend Validation:
ProviderForm
component (/keep-ui/app/providers/provider-form.tsx
), integrate the validation schema.Update Backend Validation:
Add Type Definitions:
ProviderAuthConfig
interface in /keep-ui/app/providers/providers.tsx
to include types for inputs.Frontend:
/keep-ui/app/providers/provider-form.tsx
: Main file to update for frontend validation./keep-ui/app/providers/providers.tsx
: Update the ProviderAuthConfig
interface to include input types.Backend:
Security:
Stability:
Potential Bugs:
ProviderAuthConfig
interface in /keep-ui/app/providers/providers.tsx
for existing configurations.Here's an example of how you might define a validation schema using Yup
:
import * as Yup from 'yup';
const providerInputSchema = Yup.object().shape({
provider_name: Yup.string().required('Provider name is required'),
url: Yup.string().url('Invalid URL format').required('URL is required'),
host: Yup.string().matches(/^[a-zA-Z0-9.-]+$/, 'Invalid host format').required('Host is required'),
port: Yup.number().min(1).max(65535, 'Invalid port number'),
// Add other fields as necessary
});
ProviderForm
Update the validateForm
function in ProviderForm
to use the schema:
const validateForm = (updatedFormValues) => {
try {
providerInputSchema.validateSync(updatedFormValues, { abortEarly: false });
setInputErrors({});
return {};
} catch (validationErrors) {
const errors = validationErrors.inner.reduce((acc, error) => {
acc[error.path] = error.message;
return acc;
}, {});
setInputErrors(errors);
return errors;
}
};
/attempt #1327
Algora profile | Completed bounties | Tech | Active attempts | Options |
---|---|---|---|---|
@Anshgrover23 | 1 bounty from 1 project | JavaScript |
Cancel attempt |
/attempt #1327
Keep need cross-all-providers accepted schemas for provider inputs.
this should be enforced both on frontend (for quickly tell the user what's wrong) and backend (enforcements)