Skip to content

Commit 7e3279d

Browse files
author
Luke Hinds
authored
Provider strings are not correctly validated for empty strings (#1394)
* Provider strings are not correctly validated for empty strings * Lint check
1 parent b8d7b65 commit 7e3279d

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""Update empty provider endpoint names with placeholders
2+
3+
Revision ID: 736fb0c10480
4+
Revises: e4c05d7591a8
5+
Create Date: 2025-05-01 19:17:41.766575
6+
7+
"""
8+
9+
from typing import Sequence, Union
10+
11+
from alembic import op
12+
import sqlalchemy as sa
13+
14+
15+
# revision identifiers, used by Alembic.
16+
revision: str = "736fb0c10480"
17+
down_revision: Union[str, None] = "e4c05d7591a8"
18+
branch_labels: Union[str, Sequence[str], None] = None
19+
depends_on: Union[str, Sequence[str], None] = None
20+
21+
22+
def upgrade() -> None:
23+
# ### commands auto generated by Alembic - please adjust! ###
24+
op.execute(
25+
"""
26+
UPDATE provider_endpoints
27+
SET name = 'placeholder_' || id
28+
WHERE name = ''
29+
"""
30+
)
31+
# ### end Alembic commands ###
32+
33+
34+
def downgrade() -> None:
35+
# ### commands auto generated by Alembic - please adjust! ###
36+
# Downgrading is complex as we don't know which names were placeholders.
37+
# We'll leave this empty, assuming the model validation change is permanent.
38+
pass
39+
# ### end Alembic commands ###

src/codegate/api/v1_models.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import datetime
22
import json
33
from enum import Enum
4-
from typing import Any, Dict, List, Optional, Union
4+
from typing import Annotated, Any, Dict, List, Optional, Union
55

66
import pydantic
7+
from pydantic import Field
78

89
import codegate.muxing.models as mux_models
910
from codegate.db import models as db_models
@@ -268,7 +269,7 @@ class ProviderEndpoint(pydantic.BaseModel):
268269

269270
# This will be set on creation
270271
id: Optional[str] = ""
271-
name: str
272+
name: Annotated[str, Field(min_length=3)]
272273
description: str = ""
273274
provider_type: db_models.ProviderType
274275
endpoint: str = "" # Some providers have defaults we can leverage

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy