-
Notifications
You must be signed in to change notification settings - Fork 2
Description
🧩 Analysis chain
Inner exception assertion may be brittle here.
For text/html responses without a matching deserializer, RequestHandler throws RestClientException directly (no inner exception). Please verify if MissingMethodException is actually produced; if not, drop or relax this assertion.
Run to confirm behavior across repo:
🏁 Script executed:
#!/usr/bin/env bash
# Inspect deserializer coverage for text/html and where MissingMethodException could arise
rg -n --type cs 'GetDeserializer\(|IDeserializer|text/html|MissingMethodException'Length of output: 3045
---
🏁 Script executed:
```shell
#!/bin/bash
# Examine RequestHandler line 548 and surrounding context
cat "Activout.RestClient/Implementation/RequestHandler.cs" | sed -n '540,560p'
Length of output: 809
🏁 Script executed:
#!/bin/bash
# Examine DefaultDomainExceptionMapper line 39 and surrounding context
cat "Activout.RestClient/DomainExceptions/DefaultDomainExceptionMapper.cs" | sed -n '30,50p'Length of output: 814
🏁 Script executed:
#!/bin/bash
# Examine test file context around line 118
cat "Activout.RestClient.Newtonsoft.Json.Test/DomainExceptions/DomainExceptionErrorObjectTests.cs" | sed -n '105,130p'Length of output: 980
🏁 Script executed:
#!/bin/bash
# Check if there's a GetDeserializer return handling in RequestHandler
rg -n -A 10 'GetDeserializer.*MediaType' "Activout.RestClient/Implementation/RequestHandler.cs"Length of output: 527
---
🏁 Script executed:
```shell
#!/bin/bash
# Find RestClientException class definition and all constructors
rg -n -A 15 'class RestClientException' --type cs
Length of output: 2839
🏁 Script executed:
#!/bin/bash
# Search for where RestClientException is caught and possibly wrapped with InnerException
rg -n -B 5 -A 5 'RestClientException.*InnerException|new RestClientException.*Exception' --type csLength of output: 0
🏁 Script executed:
#!/bin/bash
# Check the complete test to understand the _myApiClient.Api() call flow
cat "Activout.RestClient.Newtonsoft.Json.Test/DomainExceptions/DomainExceptionErrorObjectTests.cs" | sed -n '1,50p'Length of output: 1546
🏁 Script executed:
#!/bin/bash
# Look for HtmlHttpResponseMessage implementation
rg -n -A 10 'HtmlHttpResponseMessage' "Activout.RestClient.Newtonsoft.Json.Test/DomainExceptions/DomainExceptionErrorObjectTests.cs"Length of output: 866
---
🏁 Script executed:
```shell
#!/bin/bash
# Search for exception handling in the test class setup and execution
cat "Activout.RestClient.Newtonsoft.Json.Test/DomainExceptions/DomainExceptionErrorObjectTests.cs" | sed -n '50,110p'
Length of output: 2058
🏁 Script executed:
#!/bin/bash
# Search for where exceptions might be caught and wrapped with InnerException
rg -n -B 3 -A 3 'catch.*Exception.*e\)' "Activout.RestClient/Implementation/RequestHandler.cs" | head -40Length of output: 216
🏁 Script executed:
#!/bin/bash
# Look for client invocation and exception handling in a method interceptor or proxy
rg -n 'throw new RestClientException' --type cs -B 2 -A 2Length of output: 1083
🏁 Script executed:
#!/bin/bash
# Search for where MissingMethodException might be caught/thrown related to RestClientException
rg -n 'MissingMethodException' --type cs -B 3 -A 3Length of output: 2715
---
🏁 Script executed:
```shell
#!/bin/bash
# Final verification: see the complete catch block after the RestClientException check
cat "Activout.RestClient/Implementation/RequestHandler.cs" | sed -n '556,575p'
Length of output: 555
🏁 Script executed:
#!/bin/bash
# Verify that line 549 is indeed the 3-param constructor call by checking surrounding context
cat "Activout.RestClient/Implementation/RequestHandler.cs" | sed -n '545,555p'Length of output: 524
Remove or correct the MissingMethodException assertion at line 118.
The Assert.IsType<MissingMethodException> check is incorrect. When no deserializer is found for text/html, RequestHandler throws RestClientException using the 3-parameter constructor (line 549), which does not set an InnerException. The InnerException property will be null, not MissingMethodException. The MissingMethodException caught in DefaultDomainExceptionMapper is unrelated—it occurs during domain exception construction, not RestClientException construction. Either remove the assertion or replace it with Assert.Null(exception.InnerException) to correctly verify the actual behavior.
🤖 Prompt for AI Agents
In
Activout.RestClient.Newtonsoft.Json.Test/DomainExceptions/DomainExceptionErrorObjectTests.cs
around lines 116 to 119, the
Assert.IsType<MissingMethodException>(exception.InnerException) is incorrect
because RestClientException constructed in RequestHandler sets no
InnerException; replace that assertion with
Assert.Null(exception.InnerException) (or remove the assertion entirely) so the
test verifies the actual behavior that InnerException is null.
Originally posted by @coderabbitai[bot] in #131 (comment)