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

Internal server error 500 due to non initialised tag #1

Closed
ghost opened this issue Aug 15, 2016 · 1 comment
Closed

Internal server error 500 due to non initialised tag #1

ghost opened this issue Aug 15, 2016 · 1 comment

Comments

@ghost
Copy link

ghost commented Aug 15, 2016

I have just starting using Siaqodbcloud service to sync data to mongodb. Currently running the SyncExample (invoices) with the SiaqoCloud-Service web app. I have configured everything as in the readme. To reproduce this, first run mongod service, then start the web app, then start the SyncExamples console app. The following error is displayed on the SyncExamples console:

Error downloading changes:The remote server returned an error: (500) Internal Server Error.

And the following debug output is displayed from the server side:

A first chance exception of type 'System.NullReferenceException' occurred in SiaqodbCloudService.dll
A first chance exception of type 'System.NullReferenceException' occurred in mscorlib.dll

After investigating, the source of the problem was found to be in the MongoDB Mapper.cs file:

foreach (string tagName in cobj.Tags.Keys) { doc[tagName] = BsonTypeMapper.MapToBsonValue(cobj.Tags[tagName]); }

This was throwing a NullReferenceException because the Tags in cobj where not initialised from the SyncExamples side. My understanding is that tags don't have to be used, but are useful from the developer's point view.

My solution was to first check that the tags were not null before doing the foreach loop:

if (cobj.Tags != null) { foreach (string tagName in cobj.Tags.Keys) { doc[tagName] = BsonTypeMapper.MapToBsonValue(cobj.Tags[tagName]); } }

After building and running, the following is displayed from the console:

Sync finished!
Uploaded:2 documents!
Downloaded:0 documents!

If this is the correct handling of this error, could you please fix??

Thanks!

@cristiursachi
Copy link
Collaborator

Thanks!
We'll fix asap.

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

No branches or pull requests

1 participant