-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add type checking when importing types from recipes #15979 #15980
Conversation
@coderabbitai review |
The
Next, I will review the associated test files to ensure they cover the new functionalities adequately. Analysis chainScripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Fetch the list of files changed in the PR
gh pr view 15980 --json files --jq '.files[].path'
Length of output: 296 Script: #!/bin/bash
# Display the contents of ContentDefinitionStep.cs for review
cat src/OrchardCore.Modules/OrchardCore.ContentTypes/RecipeSteps/ContentDefinitionStep.cs
Length of output: 3741 Actions PerformedReview triggered.
|
WalkthroughThe changes involve enhancing the robustness of content type imports in OrchardCore by introducing checks against incorrect or empty type definitions. This includes modifications to the Changes
Assessment against linked issues
The changes address the core objectives of the linked issue by implementing necessary checks and validations to prevent the import of incorrect or incomplete content types, aligning with the requirements to enhance data integrity during imports. Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
src/OrchardCore.Modules/OrchardCore.ContentTypes/RecipeSteps/ContentDefinitionStep.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When addressing review feedback, please adhere to the following:
- Please update your pull request according to feedback until it is approved by one of the core team members.
- Apply suggested changes directly so the reviewer doesn't have to eyeball the changes. These resolve themselves after applying them, and that's fine.
- Don't resolve other conversations so it's easier to track for the reviewer. Then, the reviewer will resolve them.
- Feel free to mark conversations that you addressed to keep track of them with an emoji or otherwise, just don't resolve them.
- Please keep conversations happening in line comments in those convos, otherwise, communication will be a mess. If you have trouble finding them, see this video.
- When you're done addressing all feedback of a review, click "Re-request review" in the top-right corner for each reviewer when you're ready for another round of review, so they know that you're done.
src/OrchardCore.Modules/OrchardCore.ContentTypes/RecipeSteps/ContentDefinitionStep.cs
Outdated
Show resolved
Hide resolved
catch (Exception ex) | ||
{ | ||
Assert.Equal("Failed to add part to ContentType 'Message', The PartName property is not allowed to be empty", ex.Message); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Assert.ThrowsAsync()
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, always learning something new from you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DONE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm glad :).
"Name": "Message", | ||
"DisplayName": "Message", | ||
"Settings": { | ||
"ContentTypeSettings": { | ||
"Creatable": true, | ||
"Draftable": true, | ||
"Versionable": true, | ||
"Listable": true, | ||
"Securable": true | ||
} | ||
}, | ||
"ContentTypePartDefinitionRecords": [ | ||
{ | ||
"PartName": "Message", | ||
"Name": "Message", | ||
"Settings": { | ||
"ContentTypePartSettings": { | ||
"Position": "5" | ||
} | ||
} | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these really needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try it, I'm not sure, but I think this recipe is closer to the real scenario.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
…ontentDefinitionStep.cs Co-authored-by: Zoltán Lehóczky <zoltan.lehoczky@lombiq.com>
Co-authored-by: Zoltán Lehóczky <zoltan.lehoczky@lombiq.com>
@coderabbitai review |
Actions PerformedReview triggered.
|
src/OrchardCore.Modules/OrchardCore.ContentTypes/RecipeSteps/ContentDefinitionStep.cs
Outdated
Show resolved
Hide resolved
…ontentDefinitionStep.cs Co-authored-by: Mike Alhayek <mike@crestapps.com>
Co-authored-by: Mike Alhayek <mike@crestapps.com>
Co-authored-by: Mike Alhayek <mike@crestapps.com>
Co-authored-by: Mike Alhayek <mike@crestapps.com>
Co-authored-by: Mike Alhayek <mike@crestapps.com>
src/OrchardCore.Modules/OrchardCore.ContentTypes/RecipeSteps/ContentDefinitionStep.cs
Show resolved
Hide resolved
@@ -91,6 +92,10 @@ public async Task<IActionResult> Import(IFormFile importedPackage) | |||
|
|||
await _notifier.SuccessAsync(H["Deployment package imported."]); | |||
} | |||
catch (Exception ex) | |||
{ | |||
await _notifier.ErrorAsync(H[ex.Message]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @MikeAlhayek ,Can you help me see what's wrong with my localization? Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can't do that. the use of H and S must be a literal string since this has to be extracted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the notifier needs a HtmlLocalizedString
... What should I do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I can send the notify in Step logic?
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a layer of exception catching message alerts, as there is currently no exception handling when a recipe is imported.
you can't do that. the use of H and S must be a literal string since this has to be extracted.
Since the string is already processed internally, no additional processing should be required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to write the exception to the user using notifier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to write the exception to the user using notifier.
I'm not sure I agree with this. Assuming that the person who has access to import recipes has full administrative access to the system, (I can't actually guess what other person roles have access to import recipes)
it makes sense to throw some underlying exceptions directly to the user, as most Windows applications do, so that the user can view the exceptions directly through the page rather than having to log in to the server to view the logs.
(I've developed a special feature to view log files online for this purpose~)
Currently our recipe import page does nothing, which would make the user feel that the system is very unreliable After all, we can't anticipate all exceptions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can submit another PR to address another issue. I suggest keeping this PR simple and doing that type check without worrying about exception handling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, got it. Thanks.
Guys, the level of activity under this PR is disproportionally big compared to the amount of proposed changes :). I'll check out from here, and if you think my input is also required, please just @ me. |
Agreed. Same here. After I approved it there way many changes. |
@hyzx86 please revert the latest changes and keep the check that we agreed on, it seems everyone here are check out :) |
|
||
public ContentDefinitionStep(IContentDefinitionManager contentDefinitionManager) | ||
public ContentDefinitionStep(IContentDefinitionManager contentDefinitionManager, IStringLocalizer<ContentDefinitionStep> s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still needed? If so, change s to stringLozalizer
try fix #15979
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Documentation