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

Photos API throws when there are no photos #2673

Open
andre-ss6 opened this issue Sep 19, 2024 · 0 comments
Open

Photos API throws when there are no photos #2673

andre-ss6 opened this issue Sep 19, 2024 · 0 comments
Labels
type:bug A broken experience

Comments

@andre-ss6
Copy link

Describe the bug

I'm trying to fetch user profile photos. However, calling the API for users that haven't set their profile photo returns 404 with an exception message. The issue is that the Graph SDK currently throws in that case and there is no way to previously check if the user has or not a photo, so the only alternative left is to always try/catch.

Expected behavior

Either return null, some kind of empty type or provide an API for querying the photo count

How to reproduce

Invoke _graphClient.Users["[email protected]"].Photos.GetAsync(). Result: Exception: Microsoft.Graph.Models.ODataErrors.ODataError: Exception of type 'Microsoft.Fast.Profile.Core.Exception.ImageNotFoundException' was thrown.

SDK Version

5.58.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ``` Exception: Microsoft.Graph.Models.ODataErrors.ODataError: Exception of type 'Microsoft.Fast.Profile.Core.Exception.ImageNotFoundException' was thrown. at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.ThrowIfFailedResponseAsync(HttpResponseMessage response, Dictionary`2 errorMapping, Activity activityForAttributes, CancellationToken cancellationToken) at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendPrimitiveAsync[ModelType](RequestInformation requestInfo, Dictionary`2 errorMapping, CancellationToken cancellationToken) at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendPrimitiveAsync[ModelType](RequestInformation requestInfo, Dictionary`2 errorMapping, CancellationToken cancellationToken) at Microsoft.Graph.Users.Item.Photos.Item.Value.ContentRequestBuilder.GetAsync(Action`1 requestConfiguration, CancellationToken cancellationToken) at [redacted].MessageOnPRActivity.Run(HttpRequest req) in [redacted]\MessageOnPRActivity.cs:line 184 at [redacted].DirectFunctionExecutor.ExecuteAsync(FunctionContext context) in [redacted]\obj\Debug\net8.0\Microsoft.Azure.Functions.Worker.Sdk.Generators\Microsoft.Azure.Functions.Worker.Sdk.Generators.FunctionExecutorGenerator\GeneratedFunctionExecutor.g.cs:line 38 at Microsoft.Azure.Functions.Worker.OutputBindings.OutputBindingsMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a\_work\1\s\src\DotNetWorker.Core\OutputBindings\OutputBindingsMiddleware.cs:line 13 at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.FunctionsHttpProxyingMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a\_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\FunctionsMiddleware\FunctionsHttpProxyingMiddleware.cs:line 48 at Microsoft.Azure.Functions.Worker.FunctionsApplication.InvokeFunctionAsync(FunctionContext context) in D:\a\_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 89 Stack: at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.ThrowIfFailedResponseAsync(HttpResponseMessage response, Dictionary`2 errorMapping, Activity activityForAttributes, CancellationToken cancellationToken) at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendPrimitiveAsync[ModelType](RequestInformation requestInfo, Dictionary`2 errorMapping, CancellationToken cancellationToken) at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendPrimitiveAsync[ModelType](RequestInformation requestInfo, Dictionary`2 errorMapping, CancellationToken cancellationToken) at Microsoft.Graph.Users.Item.Photos.Item.Value.ContentRequestBuilder.GetAsync(Action`1 requestConfiguration, CancellationToken cancellationToken) at [redacted].MessageOnPRActivity.Run(HttpRequest req) in [redacted]\MessageOnPRActivity.cs:line 184 at [redacted].DirectFunctionExecutor.ExecuteAsync(FunctionContext context) in [redacted]\obj\Debug\net8.0\Microsoft.Azure.Functions.Worker.Sdk.Generators\Microsoft.Azure.Functions.Worker.Sdk.Generators.FunctionExecutorGenerator\GeneratedFunctionExecutor.g.cs:line 38 at Microsoft.Azure.Functions.Worker.OutputBindings.OutputBindingsMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a\_work\1\s\src\DotNetWorker.Core\OutputBindings\OutputBindingsMiddleware.cs:line 13 at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.FunctionsHttpProxyingMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a\_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\FunctionsMiddleware\FunctionsHttpProxyingMiddleware.cs:line 48 at Microsoft.Azure.Functions.Worker.FunctionsApplication.InvokeFunctionAsync(FunctionContext context) in D:\a\_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 89

Configuration

  • OS: Windows x64
  • Not specific to this configuration AFAIK

Other information

No response

@andre-ss6 andre-ss6 added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Sep 19, 2024
@shemogumbe shemogumbe removed the status:waiting-for-triage An issue that is yet to be reviewed or assigned label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug A broken experience
Projects
None yet
Development

No branches or pull requests

2 participants