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

Netkan.exe should fail gracefully on files with an invalid $kref token #374

Closed
pjf opened this issue Nov 15, 2014 · 10 comments
Closed

Netkan.exe should fail gracefully on files with an invalid $kref token #374

pjf opened this issue Nov 15, 2014 · 10 comments
Labels
Bug Something is not working as intended Discussion needed Easy This is easy to fix Enhancement New features or functionality Netkan Issues affecting the netkan data Spec Issues affecting the spec

Comments

@pjf
Copy link
Member

pjf commented Nov 15, 2014

I thought it did, but recent reports indicate that it doesn't.

It should, however, warn tell the user if it spots a file upon which it performs no expansion.

@pjf pjf added Bug Something is not working as intended Netkan Issues affecting the netkan data Enhancement New features or functionality ★☆☆ and removed Bug Something is not working as intended labels Nov 15, 2014
@mutability
Copy link

The current failure mode for a netkan file with no $kref is this:

Unhandled Exception:
System.ArgumentNullException: Argument cannot be null.
Parameter name: input
  at System.Text.RegularExpressions.Regex.Match (System.String input, Int32 startat) [0x00000] in <filename unknown>:0 
  at System.Text.RegularExpressions.Regex.Match (System.String input) [0x00000] in <filename unknown>:0 
  at System.Text.RegularExpressions.Regex.Match (System.String input, System.String pattern, RegexOptions options) [0x00000] in <filename unknown>:0 
  at System.Text.RegularExpressions.Regex.Match (System.String input, System.String pattern) [0x00000] in <filename unknown>:0 
  at CKAN.NetKAN.MainClass.FindRemote (Newtonsoft.Json.Linq.JObject json) [0x00000] in <filename unknown>:0 
  at CKAN.NetKAN.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0 

@tips48
Copy link
Contributor

tips48 commented Dec 1, 2014

@tips48 tips48 added Easy This is easy to fix Spec Issues affecting the spec labels Dec 1, 2014
@Ippo343
Copy link
Contributor

Ippo343 commented Dec 27, 2014

This issue was moved to KSP-CKAN/CKAN-netkan#4

@pjf
Copy link
Member Author

pjf commented May 31, 2015

re-opening after repo merge

@pjf pjf reopened this May 31, 2015
@pjf pjf changed the title NetKAN should accept files without $kref / $vref tokens Netkan.exe should fail gracefully on files without $kref / $vref tokens Jun 22, 2015
RichardLake added a commit to RichardLake/CKAN that referenced this issue Jun 24, 2015
@pjf
Copy link
Member Author

pjf commented Dec 13, 2015

This still exists, with us currently getting:

247 [1] FATAL CKAN.NetKAN.Program (null) - Object reference not set to an instance of an object

However it strikes me that if we have no $kref we can just tell the user:

There is no $kref field in {0}, so netkan expansion is not needed or possible.

Or something similar. (In short, this is just a better-error-message change.)

@pjf pjf changed the title Netkan.exe should fail gracefully on files without $kref / $vref tokens Netkan.exe should fail gracefully on files without a $kref token Dec 13, 2015
@mheguy
Copy link
Contributor

mheguy commented May 18, 2016

Having no $kref at all poses no issue, having a broken $kref now gives a generic JSON deserialization error

@techman83
Copy link
Member

@plague006 would that be broken JSON? Which should be caught during testing with jsonlint I'd expect. I think this was completed during the refactor #1218 - but I'm not sure. Either way I think this can be closed now.

@mheguy
Copy link
Contributor

mheguy commented May 19, 2016

It's not broken JSON as I understand it. It validates with jsonlint without issue. Some excerpts from a test:

"$kref": "#/ckan/techman/iscool",

gives the output

348 [1] FATAL CKAN.NetKAN.Program (null) - JSON deserialization error

which is really generic and hard for users to interpret.

@mheguy mheguy changed the title Netkan.exe should fail gracefully on files without a $kref token Netkan.exe should fail gracefully on files with an invalid $kref token May 19, 2016
@ayan4m1
Copy link
Contributor

ayan4m1 commented Oct 14, 2017

My first rodeo with the NetKAN codebase. The only place I see that error message in the current codebase is https://github.com/KSP-CKAN/CKAN/blob/master/Core/Types/CkanModule.cs#L297 - having a full stack trace would be handy because that CkanModule ctor is being called somewhat frequently in my limited profiling of the current code.

@HebaruSan
Copy link
Member

Current output with "$kref": "#/ckan/techman/iscool",:

$ ../CKAN/_build/netkan.exe NetKAN/KSP-AVC.netkan 
343 [1] ERROR CKAN.CkanModule (null) - KSP-AVC missing required field download
354 [1] FATAL CKAN.NetKAN.Program (null) - KSP-AVC missing required field download

So it doesn't stop at JSON deserialization anymore, but it waits till later in the processing to complain, when it finally notices it doesn't have any URLs to download. Ideally yes, the error would specify that the $kref is invalid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is not working as intended Discussion needed Easy This is easy to fix Enhancement New features or functionality Netkan Issues affecting the netkan data Spec Issues affecting the spec
Projects
None yet
Development

No branches or pull requests

8 participants