Skip to content

Commit 6f5f2c9

Browse files
authored
fix: Return GCS signed URL instead of direct URL (#2143)
* Fix local E2E tests * Return a signed URL instead of a direct URL * Fix unit test * PR comments
1 parent 07e0159 commit 6f5f2c9

File tree

3 files changed

+346
-10
lines changed

3 files changed

+346
-10
lines changed

CONTRIBUTING.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Contribute to Chainlit
22

3-
To contribute to Chainlit, you first need to setup the project on your local machine.
3+
To contribute to Chainlit, you first need to set up the project on your local machine.
44

55
## Table of Contents
66

@@ -33,7 +33,7 @@ I've copy/pasted the whole document there, and then formatted it with prettier.
3333
> **Note**
3434
> If you are on windows, some pnpm commands like `pnpm run formatPython` won't work. You can fix this by changing the pnpm script-shell to bash: `pnpm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"` (default x64 install location, [Info](https://pnpm.io/cli/run#script-shell))
3535
36-
### Setup the repo
36+
### Set up the repo
3737

3838
With this setup you can easily code in your fork and fetch updates from the main repository.
3939

@@ -74,7 +74,7 @@ The following command will install Python dependencies, Node (pnpm) dependencies
7474

7575
```sh
7676
cd backend
77-
poetry install --with tests --with mypy --with dev
77+
poetry install --with tests --with mypy --with dev --with custom-data
7878
```
7979

8080
## Start the Chainlit server from source
@@ -83,8 +83,7 @@ Start by running `backend/hello.py` as an example.
8383

8484
```sh
8585
cd backend
86-
poetry self add poetry-plugin-shell
87-
poetry shell
86+
poetry env activate
8887
chainlit run chainlit/hello.py
8988
```
9089

@@ -113,12 +112,12 @@ This will run the backend's unit tests.
113112

114113
```sh
115114
cd backend
116-
pytest
115+
poetry run pytest --cov=chainlit
117116
```
118117

119118
### E2E tests
120119

121-
This will run end to end tests, assessing both the frontend, the backend and their interaction:
120+
This will run end to end tests, assessing both the frontend, the backend and their interaction. First install cypress with `pnpm exec cypress install`, and then run:
122121

123122
```sh
124123
pnpm test
@@ -142,5 +141,4 @@ Extremely useful for debugging!
142141

143142
```sh
144143
SINGLE_TEST=password_auth CYPRESS_OPTIONS='--headed --no-exit' pnpm test
145-
```
146-
144+
```

backend/chainlit/data/storage_clients/gcs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ def sync_upload_file(
6868

6969
blob.upload_from_string(data, content_type=mime)
7070

71+
# Return signed URL
7172
return {
7273
"object_key": object_key,
73-
"url": f"https://storage.googleapis.com/{self.bucket.name}/{object_key}",
74+
"url": self.sync_get_read_url(object_key),
7475
}
7576

7677
except Exception as e:

0 commit comments

Comments
 (0)