Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trimming contentString #149

Merged
merged 2 commits into from
Feb 2, 2024
Merged

trimming contentString #149

merged 2 commits into from
Feb 2, 2024

Conversation

frogcjn
Copy link
Contributor

@frogcjn frogcjn commented Jan 27, 2024

stringContent may contain a prefix new line ("\n") before the first "data:" separator.

What

When query with chat streaming API, the response may contain a prefix new line (\n) before the first data: separator.

Affected Areas

Chat Streaming APIs

stringContent may contain a prefix new line ("\n") before the first "data:" separator.
@ingvarus-bc
Copy link
Contributor

Hi, @frogcjn, thanks for your interest in the project and for your PR.
It seems like character trimming for each data component is already being done on line 63:

.map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }

So, I am not exactly sure we need to do that twice. What do you think?

@frogcjn
Copy link
Contributor Author

frogcjn commented Feb 2, 2024

There are some cases there is "\n" before the "data:", and nothing before "\n".

The first element is "\n" after separate by "data:".

After the line63 trimming, the first still exists and it becomes empty

then the first empty string will raise error when decoding JSON.

@ingvarus-bc
Copy link
Contributor

Got you, thanks!

Copy link

sonarcloud bot commented Feb 2, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@ingvarus-bc ingvarus-bc merged commit 25f93ee into MacPaw:main Feb 2, 2024
4 checks passed
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.

None yet

2 participants