Skip to content

[swift] [urlsession] Fixes crash for uploads with content-type "image/" #21544

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Jonas1893
Copy link
Contributor

@Jonas1893 Jonas1893 commented Jul 11, 2025

Fixes a crash in urlsession templates if Content-Type with prefix "image/" is used for image upload. Issue -> #21539
The same issue should also be happening in Alamofire templates but there the solution doesn't look as trivial and I am not comfortable making the change without extended testing.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
    @jgavris (2017/07) @ehyche (2017/08) @Edubits (2017/09) @jaz-ah (2017/09) @4brunu (2019/11) @dydus0x14 (2023/06)

Declaration

The program was tested solely for our own use cases, which might differ from yours.

Link to provider information

https://github.com/mercedes-benz

@4brunu
Copy link
Contributor

4brunu commented Jul 11, 2025

Hi @Jonas1893 can you please take a look at CI? Thanks

@Jonas1893
Copy link
Contributor Author

Hi @Jonas1893 can you please take a look at CI? Thanks

  1. Samples generation failed for unrelated reasons.
  2. running ./swift6_test_all works locally, not sure why the tests are failing.

Can we re-trigger CI?

@4brunu 4brunu closed this Jul 11, 2025
@4brunu 4brunu reopened this Jul 11, 2025
@4brunu
Copy link
Contributor

4brunu commented Jul 11, 2025

Done. You can also do it, you just need to close and reopen the PR.

@Jonas1893 Jonas1893 closed this Jul 11, 2025
@Jonas1893 Jonas1893 reopened this Jul 11, 2025
@Jonas1893
Copy link
Contributor Author

@4brunu the tests always fail with a crash in xcpretty 0.4.0:

/Users/vagrant/.asdf/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/xcpretty-0.4.0/lib/xcpretty/parser.rb:366:in `parse': uninitialized constant XCPretty::Parser::ERB (NameError)

It looks like this exact issue has been fixed with 0.4.1:
xcpretty/xcpretty@fbe3f01

We need to update xcpretty to latest version. Not sure how this is been done for this project though, can you help me with this?

@Jonas1893
Copy link
Contributor Author

Found it. Bitrise is configured using this image: https://bitrise.io/stacks/stack_reports/osx-xcode-16.0.x which has xcpretty 0.4.0 preinstalled. We need at least this image: https://bitrise.io/stacks/stack_reports/osx-xcode-16.3.x

@Jonas1893
Copy link
Contributor Author

For the error we get during samples generation step on linux there is this open issue for setup-swift GitHub action: swift-actions/setup-swift#739
It's a known issue

@Jonas1893
Copy link
Contributor Author

Ok now I get test execution errors definitely unrelated to my change in apiNonStaticMethod because this configuration relies on Alamofire and not on the URLSession templates I changed. However I can also reproduce the issues locally for every library.
I am not sure how to fix this as I don't understand how the test setup is supposed to work: It looks like we are querying the hosted swagger.io API and I would think that the objects we create will be changed by other users of the API as well and then the state we are expecting has already changed for the next test run.
Maybe it would be better to implement these integration tests against a local web server in the future?

@Jonas1893 Jonas1893 closed this Jul 14, 2025
@Jonas1893 Jonas1893 reopened this Jul 14, 2025
@Jonas1893
Copy link
Contributor Author

Bitrise now fails while testing alamofireLibrary, again unrelated to my change

@wing328
Copy link
Member

wing328 commented Jul 14, 2025

#21553

right looks the build failure itself, i'll take a look

@wing328
Copy link
Member

wing328 commented Jul 14, 2025

Bitrise now fails while testing alamofireLibrary, again unrelated to my change

looks like restarting it fix the build failure as shown in #21553

@wing328 wing328 closed this Jul 14, 2025
@wing328 wing328 reopened this Jul 14, 2025
@Jonas1893
Copy link
Contributor Author

Bitrise now fails while testing alamofireLibrary, again unrelated to my change

looks like restarting it fix the build failure as shown in #21553

Hi @wing328 the Bitrise failure is still happening also in your test PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants