Skip to content

Enterprise installations not recognized (throws an Exception) #2156

@boriel

Description

@boriel

Description of the bug
When listing installations for a given App ID, the deserialization of the JSON response fails with the exception:

hudson.remoting.ProxyException: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `org.kohsuke.github.GHTargetType` from String "Enterprise": not one of the values accepted for Enum class: [ORGANIZATION, USER]
 at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 756] (through reference chain: java.lang.Object[][0]->org.kohsuke.github.GHAppInstallation["target_type"])
	at PluginClassLoader for jackson2-api//com.fasterxml.jackson.databind.exc.InvalidFormatException.from(InvalidFormatException.java:67)
	at PluginClassLoader for jackson2-api//com.fasterxml.jackson.databind.DeserializationContext.weirdStringException(DeserializationContext.java:1959)
	at PluginClassLoader for jackson2-api//com.fasterxml.jackson.databind.DeserializationContext.handleWeirdStringValue(DeserializationContext.java:1245)
	at PluginClassLoader for jackson2-api//com.fasterxml.jackson.databind.deser.std.EnumDeserializer._deserializeAltString(EnumDeserializer.java:447)
	at PluginClassLoader for jackson2-api//com.fasterxml.jackson.databind.deser.std.EnumDeserializer._fromString(EnumDeserializer.java:304)
	at PluginClassLoader for jackson2-api//com.fasterxml.jackson.databind.deser.std.EnumDeserializer.deserialize(EnumDeserializer.java:273)
	at PluginClassLoader for jackson2-api//com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:138)
	at PluginClassLoader for jackson2-api//com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:399)
	at PluginClassLoader for jackson2-api//com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:185)
	at PluginClassLoader for jackson2-api//com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:218)
	at PluginClassLoader for jackson2-api//com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:342)
	at PluginClassLoader for jackson2-api//com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:2131)
	at PluginClassLoader for jackson2-api//com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1566)
	at PluginClassLoader for github-api//org.kohsuke.github.GitHubResponse.parseBody(GitHubResponse.java:104)
	at PluginClassLoader for github-api//org.kohsuke.github.GitHubPageIterator.lambda$fetch$0(GitHubPageIterator.java:147)
	at PluginClassLoader for github-api//org.kohsuke.github.GitHubClient.createResponse(GitHubClient.java:679)
	at PluginClassLoader for github-api//org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:466)
Caused: hudson.remoting.ProxyException: org.kohsuke.github.HttpException: Server returned HTTP response code: 200, message: 'null' for URL: [https://api.github.com/app/installati](https://api.github.com/app/installations)
   ...

To Reproduce
To reproduce:

  1. Install a GitHub App at the enterprise level (this is a rather new feature)
  2. do an api call to
    https://api.github.com/app/installations

The target_type field will be "Enterprise" in one of the installations returned, and the deserialization will fail.

Expected behavior
A clear and concise description of what you expected to happen.
Just return the deserialized content with this new target_type

Desktop (please complete the following information):
Does not apply

Additional context
Fixing this will require adding the ENTERPRISE type to the GHTargetType Enum here:
https://github.com/hub4j/github-api/blob/main/src/main/java/org/kohsuke/github/GHTargetType.java#L17

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions