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

Cannot delete form records programmatically in background job #1069

Closed
JensDueO opened this issue Aug 22, 2023 · 3 comments
Closed

Cannot delete form records programmatically in background job #1069

JensDueO opened this issue Aug 22, 2023 · 3 comments
Labels
release/8.13.11 state/sprint-candidate We're trying to get this in a sprint at HQ in the next few weeks type/bug

Comments

@JensDueO
Copy link

JensDueO commented Aug 22, 2023

Bug summary

When trying to delete form records in a (Hangfire) background job, IRecordService.Delete() throws a httpContext null reference exception.

The problem was fixed in version 9.x in issue #779, but I am running forms version 8.13.7.

Reproduction

When trying to delete form records in a (Hangfire) background job, IRecordService.Delete() throws a httpContext null reference exception. The method Delete takes two parameters; a form and a record, and both parameters are valid (and not null).
See stack trace below for more information.

Specifics

Forms version 8.13.7
Calling IRecordService.Delete()

Steps to reproduce

Call IRecordService.Delete() from a Hangfire task

Expected result

Record is deleted

Actual result

Throws exception:
System.ArgumentNullException: Value cannot be null.
Parameter name: httpContext

Call stack:
at System.Web.HttpContextWrapper..ctor(HttpContext httpContext)
at Umbraco.Forms.Core.Services.WorkflowService.ExecuteWorkflows(List`1 workflows, RecordEventArgs e)
at Umbraco.Forms.Core.Services.WorkflowService.ExecuteWorkflows(Record record, Form form, FormState state, Boolean editMode)
at Umbraco.Forms.Core.Services.RecordService.Delete(Record record, Form form)
at Brand.Energy.Core.Repositories.UmbracoFormsRepository.DeleteRecord(Form form, Record record) in Brand.Energy.Core\Repositories\DeleteFormReceiptRepository.cs:line 31

Possible fix

In may 2022, you fixed the issue in version 9.4.2, but out solution is running version 8.13.7.

Look in issue #779 : Cannot delete form records programmatically in background job.

The old issue was handled by @AndyButland


This item has been added to our backlog AB#32180

@AndyButland
Copy link

It looks like a related issue, but not quite the same. In this case we are getting an exception in the processing of workflows that trigger on the delete of a record when not running within an HTTP context. Looks like we can apply a similar fix though.

@AndyButland AndyButland added type/bug state/sprint-candidate We're trying to get this in a sprint at HQ in the next few weeks labels Aug 22, 2023
@JensDueO
Copy link
Author

Wow! That is fast bug-fixing. Less than an hour from I opened the issue, to a fix is added, and the issue is closed. Thanks.

@AndyButland
Copy link

Well, we still need to release it... but you can expect that with the next patch releases, likely in a couple of weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release/8.13.11 state/sprint-candidate We're trying to get this in a sprint at HQ in the next few weeks type/bug
Projects
None yet
Development

No branches or pull requests

2 participants