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

ODL7 throwing "The ODataMessageWriterSetting.ODataUri must be set when writing individual property" when ODataMessageWriterSetting.ODataUri is set. #1022

Closed
xuzhg opened this issue Dec 22, 2017 · 1 comment
Assignees
Labels

Comments

@xuzhg
Copy link
Member

xuzhg commented Dec 22, 2017

Last issue with moving MS Graph to ODLv7.

Our TestComposibleFunctionReturningComplexType unit test which tries to write { value: "value1" } response for a GET ens/id/microsoft.graph.F8/P1 request using the attached CSDL fails with the below exception:

Microsoft.OData.ODataException occurred
  HResult=-2146233079
  Message=The ODataMessageWriterSetting.ODataUri must be set when writing individual property.
  Source=Microsoft.OData.Core
  StackTrace:
       at Microsoft.OData.ODataContextUriBuilder.ValidateResourcePath(ODataContextUrlInfo contextUrlInfo)
       at Microsoft.OData.ODataContextUriBuilder.BuildContextUri(ODataPayloadKind payloadKind, ODataContextUrlInfo contextInfo)
       at Microsoft.OData.JsonLight.ODataJsonLightSerializer.WriteContextUriProperty(ODataPayloadKind payloadKind, Func`1 contextUrlInfoGen, ODataContextUrlInfo parentContextUrlInfo, String propertyName)
       at Microsoft.OData.JsonLight.ODataJsonLightPropertySerializer.<>c__DisplayClass5_0.<WriteTopLevelProperty>b__0()
       at Microsoft.OData.JsonLight.ODataJsonLightSerializer.WriteTopLevelPayload(Action payloadWriterAction)
       at Microsoft.OData.JsonLight.ODataJsonLightPropertySerializer.WriteTopLevelPro c:\git\AD\AggregatorService\src\dev\UnitTests\Controller.UnitTest\Resources\Ops.csdl perty(ODataProperty property)
       at Microsoft.OData.JsonLight.ODataJsonLightOutputContext.WritePropertyImplementation(ODataProperty property)
       at Microsoft.OData.JsonLight.ODataJsonLightOutputContext.WriteProperty(ODataProperty property)
       at Microsoft.OData.ODataMessageWriter.<>c__DisplayClass55_0.<WriteProperty>b__0(ODataOutputContext context)
       at Microsoft.OData.ODataMessageWriter.WriteToOutput(ODataPayloadKind payloadKind, Action`1 writeAction)
       at Microsoft.OData.ODataMessageWriter.WriteProperty(ODataProperty property)
       at Microsoft.Online.AggregatorService.Controller.ODataResponseWriter.WriteResponse(RequestContext context, JObject jsonObject, ParsedRequestState state, Stream responseStream, Boolean disableStreamDisposal) in c:\git\AD\AggregatorService\src\dev\Controller\ODataResponseWriter.cs:line 339
  InnerException:

The ODataMessageWriterSetting.ODataUri is actually set:
writerSettings.ODataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses).ToString() returns:
returns http://localgateway/beta/ens('id')/microsoft.graph.F8/P1

Assemblies affected

Which assemblies and versions are known to be affected e.g. OData .Net lib 7.3

Reproduce steps

If we set the path as "~/entityset/key/operation/property" as below:

http://localgateway/beta/ens('id')/microsoft.graph.F8/P1

 ODataMessageWriterSettings writerSettings = new ODataMessageWriterSettings
{
         PayloadBaseUri = new Uri("http://localhost"),
         Version = ODataVersion.V4,
         ODataUri = new ODataUri
         {
               Path = path, // Here
               ServiceRoot = new Uri("http://localhost")
         }
 };

It will throw exception when serialize the top level property.

Expected result

Pass.

Actual result

Throw exception.
What is actually happening.

Additional detail

Optional, details of the root cause if known. Delete this section if you have no additional details to add.

@mikepizzo
Copy link
Member

Fixed by PR #1023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants