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

Fix http kref validation #2811

Merged
merged 1 commit into from
Jun 26, 2019
Merged

Fix http kref validation #2811

merged 1 commit into from
Jun 26, 2019

Conversation

HebaruSan
Copy link
Member

@HebaruSan HebaruSan commented Jun 26, 2019

Problem

Currently some modules are failing with this error:

image

3470 [1] FATAL CKAN.NetKAN.Program (null) - Object must implement IConvertible.
3471 [1] FATAL CKAN.NetKAN.Program (null) -   at System.Convert.ChangeType (System.Object value, System.Type conversionType, System.IFormatProvider provider) <0x7f7b13af7110 + 0x004d1> in <6649516e5b3542319fb262b421af0adb>:0 
  at Newtonsoft.Json.Linq.Extensions.Convert[T,U] (T token) [0x000f7] in <840a99bb54b8423b94f0716f18cfa664>:0 
  at Newtonsoft.Json.Linq.Extensions.Value[T,U] (System.Collections.Generic.IEnumerable`1[T] value) [0x0000b] in <840a99bb54b8423b94f0716f18cfa664>:0 
  at Newtonsoft.Json.Linq.Extensions.Value[U] (System.Collections.Generic.IEnumerable`1[T] value) [0x00000] in <840a99bb54b8423b94f0716f18cfa664>:0 
  at NJsonSchema.Validation.JsonSchemaValidator.ValidateString (Newtonsoft.Json.Linq.JToken token, NJsonSchema.JsonSchema schema, NJsonSchema.JsonObjectType type, System.String propertyName, System.String propertyPath, System.Collections.Generic.List`1[T] errors) [0x00043] in <840a99bb54b8423b94f0716f18cfa664>:0 
  at NJsonSchema.Validation.JsonSchemaValidator.ValidateType (Newtonsoft.Json.Linq.JToken token, NJsonSchema.JsonSchema schema, System.String propertyName, System.String propertyPath, System.Collections.Generic.List`1[T] errors) [0x001b4] in <840a99bb54b8423b94f0716f18cfa664>:0 
  at NJsonSchema.Validation.JsonSchemaValidator.Validate (Newtonsoft.Json.Linq.JToken token, NJsonSchema.JsonSchema schema, System.String propertyName, System.String propertyPath) [0x00036] in <840a99bb54b8423b94f0716f18cfa664>:0 
  at NJsonSchema.Validation.JsonSchemaValidator.ValidateProperties (Newtonsoft.Json.Linq.JToken token, NJsonSchema.JsonSchema schema, System.String propertyName, System.String propertyPath, System.Collections.Generic.List`1[T] errors) [0x00097] in <840a99bb54b8423b94f0716f18cfa664>:0 
  at NJsonSchema.Validation.JsonSchemaValidator.Validate (Newtonsoft.Json.Linq.JToken token, NJsonSchema.JsonSchema schema, System.String propertyName, System.String propertyPath) [0x0004e] in <840a99bb54b8423b94f0716f18cfa664>:0 
  at NJsonSchema.Validation.JsonSchemaValidator.Validate (Newtonsoft.Json.Linq.JToken token, NJsonSchema.JsonSchema schema) [0x0000f] in <840a99bb54b8423b94f0716f18cfa664>:0 
  at NJsonSchema.JsonSchema.Validate (Newtonsoft.Json.Linq.JToken token) [0x0000c] in <840a99bb54b8423b94f0716f18cfa664>:0 
  at CKAN.NetKAN.Validators.ObeysCKANSchemaValidator.Validate (CKAN.NetKAN.Model.Metadata metadata) [0x0001e] in <840a99bb54b8423b94f0716f18cfa664>:0 
  at CKAN.NetKAN.Validators.CkanValidator.Validate (CKAN.NetKAN.Model.Metadata metadata) [0x00019] in <840a99bb54b8423b94f0716f18cfa664>:0 
  at CKAN.NetKAN.Validators.CkanValidator.ValidateCkan (CKAN.NetKAN.Model.Metadata metadata, CKAN.NetKAN.Model.Metadata netkan) [0x00001] in <840a99bb54b8423b94f0716f18cfa664>:0 
  at CKAN.NetKAN.Processors.Inflator.Inflate (System.String filename, CKAN.NetKAN.Model.Metadata netkan, System.Nullable`1[T] releases) [0x000bf] in <840a99bb54b8423b94f0716f18cfa664>:0 
  at CKAN.NetKAN.Program.Main (System.String[] args) [0x00150] in <840a99bb54b8423b94f0716f18cfa664>:0 

Cause

Looking for commonalities among HyperEdit, Graphotron, and Kethane, they are 3 of the 5 $krefs using #/ckan/http/ (SurveyTransponder and TalisarParts being the others, each last checked by the bot 21 hours ago). HttpTransformer is assigning a Uri object into the JToken structure:

var resolvedUri = Net.ResolveRedirect(new Uri(metadata.Kref.Id));
Log.InfoFormat("URL {0} resolved to {1}", metadata.Kref.Id, resolvedUri);
if (resolvedUri != null)
{
json["download"] = resolvedUri;

public static Uri ResolveRedirect(Uri uri)

When NJsonSchema and Newtonsoft try to validate that Uri object where they are expecting a string, they fail.

Changes

Now we convert the Uri to a string before storing it in the JToken structure, which allows it to validate.

@HebaruSan HebaruSan added Bug Easy This is easy to fix Netkan Issues affecting the netkan data Pull request labels Jun 26, 2019
@HebaruSan HebaruSan merged commit c16f43e into KSP-CKAN:master Jun 26, 2019
HebaruSan added a commit that referenced this pull request Jun 26, 2019
@HebaruSan HebaruSan deleted the fix/http-uri branch June 26, 2019 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Easy This is easy to fix Netkan Issues affecting the netkan data Pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants