Skip to content

Credentials: Custom Provider Input #166#177

Closed
priyanshu6238 wants to merge 11 commits intoProjectTech4DevAI:mainfrom
priyanshu6238:credential_4
Closed

Credentials: Custom Provider Input #166#177
priyanshu6238 wants to merge 11 commits intoProjectTech4DevAI:mainfrom
priyanshu6238:credential_4

Conversation

@priyanshu6238
Copy link
Copy Markdown
Contributor

Current State

  • Single-provider, rigid structure: Only one provider's credentials could be stored per organization, with a fixed structure and no support for provider-specific operations or validation.
  • Insecure deletion & inconsistent responses: Credential deletions were not safely handled (no soft deletion or data clearing), and API responses lacked standardization, leading to error-prone client handling.
  • No API key encryption for api_key in credentials.
  • No update granularity: Updating credentials replaced the entire object instead of allowing partial updates (e.g., rotating only a secret without touching metadata), which is inefficient and risky.
  • Missing input validation: Routes accepted loosely validated data (e.g., empty strings, invalid JSON) without proper checks, leading to internal crashes and unexpected behavior.
  • No error normalization: Errors like missing providers, invalid orgs, or DB issues were returned with inconsistent status codes or vague messages, complicating debugging and error handling.
  • Missing input validation: Routes accepted loosely validated data (e.g., empty strings, invalid JSON) without proper checks, leading to internal crashes and unexpected behavior.

Key Changes

  • Multi-provider support:
    Enabled storing credentials for multiple providers (e.g., OpenAI, Gemini) per organization.

  • Flexible credential structure:
    Refactored data model to handle provider-specific credential fields dynamically.

  • Soft deletion logic:
    Credentials are marked as inactive instead of being permanently deleted, allowing safer recovery.

  • Isolated provider updates:
    Updates apply only to the specified provider without overwriting other credentials.

  • Improved error handling:
    Clear and appropriate HTTP status codes are used (400, 404, 500) to aid client-side debugging.

  • Provider verification:
    Ensured that only supported providers can be added or updated using validate_provider().

  • Ran fastapi run --reload app/main.py or docker compose up in the repository root and test.

  • If you've fixed a bug or added code that is tested and has test cases.

priyanshu6238 and others added 9 commits May 10, 2025 11:21
…pecific credentials

- Introduced a new column 'provider' in the credential table to support multiple credential providers.
- Updated API routes to handle provider-specific credential operations, including creation, retrieval, updating, and deletion.
- Enhanced validation for provider credentials and added support for multiple providers in the data model.
- Refactored existing credential handling functions to accommodate the new structure and improve error handling.
- Ensured backward compatibility by maintaining existing functionality while expanding capabilities.
…reation, enhance readability, and ensure proper handling of provider-specific data.
…roper checks for credential existence; update tests for accuracy in response validation.
… and improved error responses; update tests for accurate status codes and messages.
…redential fields; improve error responses for organization checks and unexpected exceptions.
@codecov
Copy link
Copy Markdown

codecov bot commented May 10, 2025

Codecov Report

Attention: Patch coverage is 85.17350% with 47 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
backend/app/crud/credentials.py 71.42% 26 Missing ⚠️
backend/app/api/routes/credentials.py 66.10% 20 Missing ⚠️
backend/app/core/providers.py 96.29% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@priyanshu6238 priyanshu6238 changed the title Credential 4 Credentials: Custom Provider Input #166 May 10, 2025
@AkhileshNegi AkhileshNegi linked an issue May 12, 2025 that may be closed by this pull request
@AkhileshNegi
Copy link
Copy Markdown
Collaborator

cherry picked it here
#179

@AkhileshNegi AkhileshNegi removed a link to an issue May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants