Specified value has invalid HTTP Header characters.

1,678 views
Skip to first unread message

Nick Josevski

unread,
Jan 30, 2015, 2:01:18 AM1/30/15
to rav...@googlegroups.com
Hello,
 In version 2.5.2907 we ended up setting a field name in the metadata on a document with and invalid character (the '@').

I've got test code that successfully persists this document and it's invalid meta data into Raven. Now if you try to load that document via the IDE or via a session.Load<LogDocument>(id) call it'll fail with the exception below.

We've stopped doing that now, but it seems like an issue that saving the document is allowed in the first place with invalid metadata. The restriction is a set of seperator characters and US-ASCII on metadata headers.

Question
System.Net.WebHeaderCollection.CheckBadChars  Is called on the way out, could something like that be done on the way in? (I do see that is an internal method of that class...).



Regards,
Nick Josevski


Test Code
            IDocumentSession session;

            var id = Guid.NewGuid();
            var doc = new LogDocument
            {
                LogId = id
            };
            
            session.Store(doc);

            var meta = session.Advanced.GetMetadataFor(doc);

            meta["email...@example.com"] = 1;

            session.SaveChanges();

           // will fail: 
           session.Load<LogDocument>(id);


Exception:
        "Error": "System.ArgumentException: Specified value has invalid HTTP Header characters.
        Parameter name: name
        at System.Net.WebHeaderCollection.CheckBadChars(String name, Boolean isHeaderValue)
        at System.Net.WebHeaderCollection.SetInternal(String name, String value)
        at Raven.Database.Extensions.HttpExtensions.WriteHeaders(IHttpContext context, RavenJObject headers, Etag etag)
        at Raven.Database.Extensions.HttpExtensions.WriteData(IHttpContext context, Byte[] data, RavenJObject headers, Etag etag)
        at Raven.Database.Server.Responders.Document.GetDocumentDirectly(IHttpContext context, String docId)
        at Raven.Database.Server.Responders.Document.Respond(IHttpContext context)
        at Raven.Database.Server.HttpServer.DispatchRequest(IHttpContext ctx)
        at Raven.Database.Server.HttpServer.HandleActualRequest(IHttpContext ctx)"

Oren Eini (Ayende Rahien)

unread,
Jan 30, 2015, 2:17:40 AM1/30/15
to ravendb

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages