Repository navigation
Replace empty catch blocks with explicit checks and fix the ExportImpot namespace - #988
Merged
Merged
Conversation
…ot namespace - Date of birth, blog archive month and the contact form date field validate year, month and day instead of swallowing the DateTime constructor exception. - Plugin upload deletes the previous plugin folder only when it exists and no longer hides a failed delete. - System info reads the OS description and runtime version directly; neither call throws. - Grand.Business.Checkout.Services.ExportImpot is renamed to ExportImport.
…ion when it fails - UploadPlugin catches the exception and shows it through Error(exc) instead of returning a 500 - the previous plugin folder is moved into the temp upload folder rather than deleted in place, and moved back if extraction fails - ContactAttributeChangeCommandHandler parses the date field the same way as ContactAttributeParser - System info shows RuntimeInformation.FrameworkDescription - more date edge cases in the contact attribute parser test
Comment on lines
+287
to
+291
| catch (Exception exc) | ||
| { | ||
| Error(exc); | ||
| return RedirectToAction("List"); | ||
| } |
| ZipFile.ExtractToDirectory(archivePath, pluginsPath); | ||
| //move the previous version into the temp upload folder instead of deleting it in place: | ||
| //a locked assembly fails the move before anything is changed, and a failed extraction puts it back | ||
| var previousVersionPath = Path.Combine(Path.GetDirectoryName(archivePath)!, Guid.NewGuid().ToString()); |
… a loaded assembly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the architecture backlog (item N17: leftover
catch { },ExportImpottypo)Type: refactor
Issue
Seven places swallowed every exception with an empty
catch, mostly to turn an invalid date intonull. That hides real failures, and in the plugin upload it hid a failed delete of the previous plugin folder, which then surfaced later as a less clear extraction error. The order export schema also lived in a misspelled namespace,Grand.Business.Checkout.Services.ExportImpot.Solution
RegisterModel.ParseDateOfBirth,CustomerInfoModel.ParseDateOfBirth,BlogPagingFilteringModel.GetParsedMonthand the date field inContactAttributeParser.GetParseContactAttributescheck year, month and day range (DateTime.DaysInMonth) instead of catching theDateTimeconstructor exception. Invalid or missing input still givesnull/ no attribute.PluginController.Uploadno longer deletes the previous plugin folder in place. It moves it into the temp upload folder, extracts the new version, and moves the previous one back if extraction fails. On Windows a folder with an assembly the process has loaded can be moved but not deleted, so a temp folder that cannot be deleted after a finished upload is logged as a warning and removed by the next upload (the plugin loader only reads folders directly underPlugins, so the copy there is never loaded).UploadPluginnow catches upload failures and shows them throughError(exc)with a redirect to the list, instead of a 500.ContactAttributeChangeCommandHandlerparses the date field the same way asContactAttributeParser.SystemController.SystemInfosetsOperatingSystemandAspNetInfodirectly;RuntimeInformation.OSDescriptiondoes not throw, andAspNetInfonow showsRuntimeInformation.FrameworkDescription(RuntimeEnvironment.GetSystemVersion()returnedv4.0.30319on modern .NET).Services/ExportImpot→Services/ExportImport(namespaceGrand.Business.Checkout.Services.ExportImport).Breaking changes
Grand.Business.Checkout.Services.ExportImpotmust change theusing.OrderSchemaPropertyis only registered in DI; no plugin or module in this repository references it.Testing
dotnet build src/Web/Grand.Web.Admin: succeeds.Grand.Web.Tests/Models/DateParsingModelsTests(date of birth: leap day, 29 Feb in a non-leap year, month 13, 31 April, year 0, missing parts; blog month: valid, out of range, non-numeric, wrong shape, empty) and a data-driven date field test inContactAttributeParserTests(leap day, 31 April, day 0, month 0/13, year 0/1/9999/10000, non-numeric, missing year). They describe the previous behavior and pass before and after.dotnet test:ContactAttributeParserTests23/23,Grand.Web.Testsfiltered to the new tests and the customer validators 23/23,OrderSchemaPropertyTests1/1.