Skip to content

Commit b788ee8

Browse files
authored
Merge pull request #18 from Infisical/daniel/fix-strict-schema
fix: strict schema crash
2 parents 8ddf068 + 5f702ea commit b788ee8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

infisical_sdk/api_types.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from dataclasses import dataclass, field
1+
from dataclasses import dataclass, field, fields
22
from typing import Optional, List, Any, Dict
33
from enum import Enum
44
import json
@@ -34,7 +34,10 @@ def to_dict(self) -> Dict:
3434
@classmethod
3535
def from_dict(cls, data: Dict) -> 'BaseModel':
3636
"""Create model from dictionary"""
37-
return cls(**data)
37+
# Get only the fields that exist in the dataclass
38+
valid_fields = {f.name for f in fields(cls)}
39+
filtered_data = {k: v for k, v in data.items() if k in valid_fields}
40+
return cls(**filtered_data)
3841

3942
def to_json(self) -> str:
4043
"""Convert model to JSON string"""
@@ -70,6 +73,7 @@ class BaseSecret(BaseModel):
7073
secretComment: str
7174
createdAt: str
7275
updatedAt: str
76+
secretMetadata: Optional[Dict[str, Any]] = None
7377
secretReminderNote: Optional[str] = None
7478
secretReminderRepeatDays: Optional[int] = None
7579
skipMultilineEncoding: Optional[bool] = False

0 commit comments

Comments
 (0)