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

UserAgent exposed for HTTP requests #12

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

Conversation

moljac
Copy link
Contributor

@moljac moljac commented Apr 18, 2023

Seems like HttpClient has problems, in some cases, with getting info from Maven repositories.

NOTE[s]:

  • never experienced this error from local Mac builds
  • the problem was detected on CI/CD servers during binderator runs on Mac (never on Windows):
Unhandled exception. System.Collections.Generic.KeyNotFoundException: No version for artifact `accompanist-placeholder-material` with version: `0.30.1`
   at MavenNet.MavenRepository.GetProjectAsync(String groupId, String artifactId, String version)
   at AndroidBinderator.Engine.ProcessConfig(BindingConfig config) in D:\a\_work\1\s\Util\Xamarin.AndroidBinderator\Xamarin.AndroidBinderator\Engine.cs:line 65
   at AndroidBinderator.Engine.BinderateAsync(BindingConfig config) in D:\a\_work\1\s\Util\Xamarin.AndroidBinderator\Xamarin.AndroidBinderator\Engine.cs:line 46
   at Xamarin.AndroidBinderator.Tool.Program.Main(String[] args) in D:\a\_work\1\s\Util\Xamarin.AndroidBinderator\Xamarin.AndroidBinderator.Tool\Program.cs:line 67
   at Xamarin.AndroidBinderator.Tool.Program.<Main>(String[] args)
An error occurred when executing task 'binderate'.
Error: Process xamarin-android-binderator exited with code 134.

MavenNet error after adding unit-test case reveals true cause of the exception/error:

[xUnit.net 00:00:02.12]       
    System.Net.Http.HttpRequestException : 
    Response status code does not indicate success: 403 (Forbidden).

Error/exception occurs ONLY for SOME artifacts (gropuId) - in this case com.google.accompanist group.

Artifacts (repro data - urls) causing exception:

    com.google.accompanist:accompanist-appcompat-theme:0.30.1
    com.google.accompanist:accompanist-placeholder-material:0.30.1

The reason for failures for SOME artifacts, could be behind reverse proxy and database partitioning/shardening
and requests hitting SOME/SPECIFIC HTTP server[s] for those specific packages.

The solution is to add User-Agent to requests, so HttpClient was exposed, so headers can be
manipulated.

@moljac moljac marked this pull request as draft April 18, 2023 07:56
@moljac moljac marked this pull request as ready for review April 19, 2023 10:09
@moljac
Copy link
Contributor Author

moljac commented Apr 19, 2023

/azp run

@jpobst
Copy link
Collaborator

jpobst commented May 1, 2023

Note that the issue here was that Maven Central had a CDN issue where some of their servers were missing the 30.1 versions. I had them flush their CDN for these files and it should be fixed now.

Apparently I didn't bother to save my login for their JIRA, but here's the link if someone wants to create an account:
https://issues.sonatype.org/browse/MVNCENTRAL-8023

> When attempting to access this file:
> [https://repo1.maven.org/maven2/com/google/accompanist/accompanist-placeholder-material/maven-metadata.xml]
>  
> Some of our machines correctly see a version with `<lastUpdated>20230404050249</lastUpdated>` that has `<latest>0.31.0-alpha</latest>`.
> - These machines report an IP address for `repo1.maven.org` of `199.232.192.209` via `nslookup`.
>  
> However some of them retrieve a version with `<lastUpdated>20230323002739</lastUpdated>` that has `<latest>0.30.0</latest>`.
> - These machines report an IP address for `repo1.maven.org` of `151.101.20.209` via `nslookup`.
>  
> If I use a hosts file to manually point a machine that works correctly to the `151.101.20.209` IP address, it receives the incorrect file.
>  
> My guess is this is a stale CDN issue.
Joel Orlina updated MVNCENTRAL-8023:
------------------------------------
    Resolution: Fixed
        Status: Done  (was: To Do)

@moljac
Copy link
Contributor Author

moljac commented May 1, 2023

Note that the issue here was that Maven Central had a CDN issue where some of their servers were missing the 30.1 versions. I had them flush their CDN for these files and it should be fixed now.

I tested few more versions which led me into thinking that it is something with reverse proxy and DB partitioning/shardening.

OK. Let me test AX PRs and if everything is OK we can close this PR.

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

3 participants