Skip to content

Commit a0b0cc2

Browse files
committed
2.1.1
1 parent 8a557d8 commit a0b0cc2

File tree

436 files changed

+3454
-12373
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

436 files changed

+3454
-12373
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ var/
2323
*.egg-info/
2424
.installed.cfg
2525
*.egg
26+
.env.*
27+
.env
2628

2729
# PyInstaller
2830
# Usually these files are written by a python script from a template

.openapi-generator-ignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,11 @@
2121
#docs/*.md
2222
# Then explicitly reverse the ignore rule for a single file:
2323
#!docs/README.md
24+
README.md
25+
.env
26+
test/**
27+
test/*
28+
requirements.txt
29+
test-requirements.txt
30+
tox.ini
31+
pytest.ini

.openapi-generator/FILES

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
.gitignore
22
.gitlab-ci.yml
33
.travis.yml
4-
README.md
54
docs/AcceptAnInvitationRequest.md
65
docs/AcceptAnInvitationResponse.md
76
docs/AddARegistrationOrDeviceTokenRequest.md
@@ -104,8 +103,10 @@ docs/SendbirdFile.md
104103
docs/SendbirdGroupChannel.md
105104
docs/SendbirdGroupChannelDetail.md
106105
docs/SendbirdGroupChannelDetailChannel.md
106+
docs/SendbirdGroupChannelLastMessage.md
107107
docs/SendbirdMember.md
108108
docs/SendbirdMessageResponse.md
109+
docs/SendbirdMessageResponseExtendedMessagePayload.md
109110
docs/SendbirdMessageResponseMessageEvents.md
110111
docs/SendbirdOpenChannel.md
111112
docs/SendbirdParentMessageInfo.md
@@ -152,7 +153,6 @@ docs/ViewPushPreferencesForAChannelResponse.md
152153
docs/ViewPushPreferencesResponse.md
153154
docs/ViewWhoOwnsARegistrationOrDeviceTokenResponse.md
154155
git_push.sh
155-
requirements.txt
156156
sendbird_platform_sdk/__init__.py
157157
sendbird_platform_sdk/api/__init__.py
158158
sendbird_platform_sdk/api/announcement_api.py
@@ -264,8 +264,10 @@ sendbird_platform_sdk/model/sendbird_file.py
264264
sendbird_platform_sdk/model/sendbird_group_channel.py
265265
sendbird_platform_sdk/model/sendbird_group_channel_detail.py
266266
sendbird_platform_sdk/model/sendbird_group_channel_detail_channel.py
267+
sendbird_platform_sdk/model/sendbird_group_channel_last_message.py
267268
sendbird_platform_sdk/model/sendbird_member.py
268269
sendbird_platform_sdk/model/sendbird_message_response.py
270+
sendbird_platform_sdk/model/sendbird_message_response_extended_message_payload.py
269271
sendbird_platform_sdk/model/sendbird_message_response_message_events.py
270272
sendbird_platform_sdk/model/sendbird_open_channel.py
271273
sendbird_platform_sdk/model/sendbird_parent_message_info.py
@@ -314,6 +316,3 @@ sendbird_platform_sdk/models/__init__.py
314316
sendbird_platform_sdk/rest.py
315317
setup.cfg
316318
setup.py
317-
test-requirements.txt
318-
test/__init__.py
319-
tox.ini

ENV_SETUP.md

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Environment Setup for Integration Tests
2+
3+
This guide explains how to configure credentials for integration tests.
4+
5+
## Quick Start
6+
7+
1. Create a `.env` file in the project root directory
8+
2. Add your Sendbird credentials
9+
3. Run integration tests
10+
11+
## Step-by-Step Setup
12+
13+
### 1. Create .env File
14+
15+
Create a file named `.env` in the project root directory (same directory as `README.md`):
16+
17+
```bash
18+
# Navigate to project root
19+
cd /path/to/sendbird-platform-sdk-python
20+
21+
# Create .env file
22+
touch .env
23+
```
24+
25+
### 2. Add Your Credentials
26+
27+
Edit the `.env` file and add your Sendbird credentials:
28+
29+
```bash
30+
# Sendbird Platform SDK - Integration Test Configuration
31+
32+
# Your Sendbird Application ID
33+
# Find this in Sendbird Dashboard > Settings > Application > App ID
34+
SENDBIRD_APP_ID=your_app_id_here
35+
36+
# Your Sendbird API Token (Master API Token)
37+
# Find this in Sendbird Dashboard > Settings > Application > API tokens
38+
SENDBIRD_API_TOKEN=your_api_token_here
39+
```
40+
41+
### 3. Get Your Credentials
42+
43+
To find your Sendbird credentials:
44+
45+
1. Log in to [Sendbird Dashboard](https://dashboard.sendbird.com/)
46+
2. Select your application
47+
3. Go to **Settings** > **Application**
48+
4. **App ID**: Copy the Application ID
49+
5. **API Token**: Go to **API tokens** tab and copy the Master API token
50+
51+
### 4. Verify Setup
52+
53+
Run a simple test to verify your setup:
54+
55+
```bash
56+
# Test with a single integration test
57+
python -m pytest test/integration/test_user_integration.py::TestUserApiIntegration::test_list_users -v
58+
```
59+
60+
If configured correctly, the test will run (not skip).
61+
62+
## Alternative: Environment Variables
63+
64+
Instead of using a `.env` file, you can set environment variables directly:
65+
66+
```bash
67+
# Set environment variables
68+
export SENDBIRD_APP_ID=your_app_id_here
69+
export SENDBIRD_API_TOKEN=your_api_token_here
70+
71+
# Run tests
72+
python -m pytest test/integration/ -v
73+
```
74+
75+
## Security Notes
76+
77+
⚠️ **Important Security Considerations:**
78+
79+
1. **Never commit `.env` file**: The `.env` file is automatically ignored by git
80+
2. **Keep credentials secret**: Do not share your API token
81+
3. **Use test applications**: Consider using a separate Sendbird application for testing
82+
4. **Rotate tokens regularly**: Regenerate API tokens periodically
83+
5. **Limit token permissions**: Use tokens with minimal required permissions if possible
84+
85+
## Troubleshooting
86+
87+
### Tests are being skipped
88+
89+
If you see "Integration tests require SENDBIRD_APP_ID and SENDBIRD_API_TOKEN", check:
90+
91+
1. `.env` file exists in the project root (not in `test/` directory)
92+
2. Variable names are correct (case-sensitive)
93+
3. Values don't have quotes or extra spaces
94+
4. File is saved
95+
96+
### Invalid credentials
97+
98+
If tests run but fail with authentication errors:
99+
100+
1. Verify credentials in Sendbird Dashboard
101+
2. Check for typos in `.env` file
102+
3. Ensure API token has required permissions
103+
4. Try regenerating the API token
104+
105+
### .env file not loading
106+
107+
1. Ensure file is named exactly `.env` (not `.env.txt` or similar)
108+
2. File should be in project root directory
109+
3. Check file permissions (should be readable)
110+
111+
## Example .env File
112+
113+
Here's a complete example:
114+
115+
```bash
116+
# Sendbird Platform SDK - Integration Test Configuration
117+
# Created: 2024-10-15
118+
119+
# Application ID from Sendbird Dashboard
120+
SENDBIRD_APP_ID=A1B2C3D4-E5F6-7890-ABCD-EF1234567890
121+
122+
# Master API Token from Sendbird Dashboard
123+
SENDBIRD_API_TOKEN=1234567890abcdef1234567890abcdef1234567890
124+
```
125+
126+
## Additional Resources
127+
128+
- [Sendbird Platform API Documentation](https://sendbird.com/docs/chat/v3/platform-api/getting-started/prepare-to-use-api)
129+
- [Sendbird Dashboard](https://dashboard.sendbird.com/)
130+
- [Integration Test Guide](test/README.md)
131+

KNOWN_ISSUES.md

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
# Known Issues - Sendbird Platform SDK Python
2+
3+
This document tracks known issues and bugs in the SDK that are reflected in failing tests.
4+
5+
## Optional Fields Rejecting None Values
6+
7+
**Status**: 🐛 Bug
8+
**Severity**: Medium
9+
**Affected Version**: 2.1.1
10+
11+
### Description
12+
13+
Optional fields in model classes incorrectly reject `None` values. According to OpenAPI specification and general API best practices, optional fields should accept `None` values, but the current SDK implementation raises `ApiTypeError` when `None` is explicitly passed to optional fields.
14+
15+
### Expected Behavior
16+
17+
```python
18+
# This SHOULD work for optional fields
19+
model = CreateAUserRequest(
20+
nickname="John Doe",
21+
profile_url="https://example.com/profile.jpg",
22+
user_id="user123",
23+
discovery_keys=None, # Optional field - should accept None
24+
metadata=None # Optional field - should accept None
25+
)
26+
```
27+
28+
### Actual Behavior
29+
30+
```python
31+
# This currently FAILS with ApiTypeError
32+
model = CreateAUserRequest(
33+
nickname="John Doe",
34+
profile_url="https://example.com/profile.jpg",
35+
user_id="user123",
36+
discovery_keys=None # ❌ Raises: Invalid type for variable 'discovery_keys'
37+
)
38+
```
39+
40+
### Workaround
41+
42+
Instead of passing `None`, simply omit the field:
43+
44+
```python
45+
# ✅ This works
46+
model = CreateAUserRequest(
47+
nickname="John Doe",
48+
profile_url="https://example.com/profile.jpg",
49+
user_id="user123"
50+
# discovery_keys and metadata omitted - works fine
51+
)
52+
```
53+
54+
Or use empty values:
55+
56+
```python
57+
# ✅ This also works
58+
model = CreateAUserRequest(
59+
nickname="John Doe",
60+
profile_url="https://example.com/profile.jpg",
61+
user_id="user123",
62+
discovery_keys=[], # Empty list instead of None
63+
metadata={} # Empty dict instead of None
64+
)
65+
```
66+
67+
### Affected Models
68+
69+
The following models have optional fields that incorrectly reject `None`:
70+
71+
1. **AcceptAnInvitationRequest**
72+
- `access_code` (optional but not nullable)
73+
74+
2. **CreateAUserRequest**
75+
- `discovery_keys` (optional but not nullable)
76+
- `metadata` (optional but not nullable)
77+
- `profile_file` (optional but not nullable)
78+
79+
3. **SendbirdUser**
80+
- `nickname` (optional but not nullable)
81+
- `profile_url` (optional but not nullable)
82+
- `discovery_keys` (optional but not nullable)
83+
- `preferred_languages` (optional but not nullable)
84+
- `session_tokens` (optional but not nullable)
85+
- `metadata` (optional but not nullable)
86+
- **Exception**: `state` field IS nullable (correctly accepts None)
87+
88+
### Failing Tests
89+
90+
The following tests document this issue and currently fail:
91+
92+
```bash
93+
# Run these tests to see the issue
94+
pytest test/test_accept_an_invitation_request.py::TestAcceptAnInvitationRequest::testAcceptAnInvitationRequestOptionalFieldShouldAcceptNone -v
95+
pytest test/test_create_a_user_request.py::TestCreateAUserRequest::testCreateAUserRequestOptionalDiscoveryKeys -v
96+
pytest test/test_create_a_user_request.py::TestCreateAUserRequest::testCreateAUserRequestOptionalMetadata -v
97+
pytest test/test_sendbird_user.py::TestSendbirdUser::testSendbirdUserOptionalFields -v
98+
```
99+
100+
Test results:
101+
```
102+
FAILED test/test_accept_an_invitation_request.py - ApiTypeError: Invalid type for variable 'access_code'
103+
FAILED test/test_create_a_user_request.py (multiple) - ApiTypeError for optional fields
104+
FAILED test/test_sendbird_user.py (multiple) - ApiTypeError for optional fields
105+
106+
7 failed, 244 passed
107+
```
108+
109+
### Root Cause
110+
111+
This issue likely stems from the OpenAPI Generator configuration or template. The generator is not properly marking optional fields as nullable in the generated Python code.
112+
113+
In the model files, optional non-nullable fields are defined as:
114+
```python
115+
'discovery_keys': ([str],), # Should be ([str], none_type,) for nullable
116+
```
117+
118+
While properly nullable fields are defined as:
119+
```python
120+
'state': (str, none_type,), # ✅ Correctly includes none_type
121+
```
122+
123+
### Potential Solutions
124+
125+
1. **Update OpenAPI Generator Templates**
126+
- Modify the Python generator template to mark optional fields as nullable
127+
- Location: `sendbird-platform-openapi/` generator configuration
128+
129+
2. **Update OpenAPI Specification**
130+
- Explicitly mark optional fields as `nullable: true` in the YAML spec
131+
- Location: `sendbird-platform-openapi/sendbird.yaml`
132+
133+
3. **Post-Processing Script**
134+
- Create a script to automatically add `none_type` to optional fields after generation
135+
- Similar to existing `post_process_nullable_fields_auto.py`
136+
137+
### Recommendation
138+
139+
Update the OpenAPI specification or generator configuration to properly handle optional fields:
140+
141+
```yaml
142+
# In sendbird.yaml
143+
properties:
144+
discovery_keys:
145+
type: array
146+
items:
147+
type: string
148+
nullable: true # Add this for optional fields
149+
```
150+
151+
### References
152+
153+
- OpenAPI Specification: [Nullable](https://swagger.io/docs/specification/data-models/data-types/#null)
154+
- Python OpenAPI Generator: [Issues with nullable](https://github.com/OpenAPITools/openapi-generator/issues?q=nullable+python)
155+
- Related test files:
156+
- `test/test_accept_an_invitation_request.py`
157+
- `test/test_create_a_user_request.py`
158+
- `test/test_sendbird_user.py`
159+
160+
---
161+
162+
**Last Updated**: 2025-10-16
163+
**Reported By**: Automated Test Suite
164+
**Priority**: Medium - Affects developer experience but has workarounds
165+

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,9 @@ All the documentation for this project lives in the /docs directory of this repo
6767
| | Documentation |
6868
| ----------- | ----------- |
6969
| Announcement | [docs/AnnouncementApi.md](docs/AnnouncementApi.md)|
70-
| Application | [docs/ApplicationApi.md](docs/ApplicationApi.md) |
7170
| Bot | [docs/BotApi.md](docs/BotApi.md) |
7271
| GroupChannel | [docs/GroupChannelApi.md](docs/GroupChannelApi.md) |
7372
| Message | [docs/MessageApi.md](docs/MessageApi.md) |
7473
| OpenChannel | [docs/OpenChannelApi.md ](docs/OpenChannelApi.md) |
7574
| User | [docs/UserApi.md](docs/UserApi.md) |
76-
75+
| Moderation | [docs/ModerationApi.md](docs/ModerationApi.md) |

0 commit comments

Comments
 (0)