Teardown error: System.InvalidOperationException: The context data has not been setup.
- Dominant language
- C#
- Stars
- 4.2k
- Forks
- 778
- Avg merge
- 3h 37m
- Merged PRs (30d)
- 21
Description
Cake 0.33.0 (Windows x64) throws the following error:
```
----------------------------------------
Teardown
----------------------------------------
An error occurred in a custom teardown action.
Teardown error: System.InvalidOperationException: The context data has not been setup.
at Cake.Core.CakeDataService.Get[TData]()
at Cake.Core.CakeEngineActions.<>c__DisplayClass21_0`1.b__0(ITeardownContext context)
at Cake.Core.DefaultExecutionStrategy.PerformTeardown(Action`1 action, ITeardownContext teardownContext)
at Cake.Core.CakeEngine.PerformTeardown(IExecutionStrategy strategy, ICakeContext context, Stopwatch stopWatch, CakeReport report, Boolean exceptionWasThrown, Exception thrownException)
Error: One or more errors occurred.
Object reference not set to an instance of an object.
```
This happens after implementing a typed context as described in https://cakebuild.net/docs/fundamentals/sharing-build-state
It happens if the Setup task throws an exception. in this case the BuildData object is not returned. I also have a TearDown task and that seems to cause the error.
The biggest problem is that the original exception is lost, so troubleshooting issues with the Setup task is very difficult.
Contributor guide
Research direction
Reproduce the typed-context scenario where Setup throws and TearDown then reports the context-data error. Start with Cake.Core.CakeDataService.Get(), CakeEngineActions.RegisterTeardown, and CakeEngine.PerformTeardown; done means the original Setup exception remains available instead of being replaced by the teardown error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100