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

feat(webapi): Add flag for disabling SystemLabel reset #1921

Merged
merged 1 commit into from
Feb 20, 2025

Conversation

oskogstad
Copy link
Collaborator

Description

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

Documentation

  • Documentation is updated (either in docs-directory, Altinnpedia or a separate linked PR in altinn-studio-docs., if applicable)

@oskogstad oskogstad requested a review from a team as a code owner February 20, 2025 10:31
Copy link
Contributor

coderabbitai bot commented Feb 20, 2025

📝 Walkthrough

Walkthrough

This pull request introduces enhancements to control the system label reset functionality. A new constant is added to clearly document the admin scope requirement for disabling the reset, while multiple command and request classes are extended with a new boolean property, DisableSystemLabelReset. The changes update the control flow in the respective handlers and endpoints so that when the property is enabled and the user lacks administrative privileges, a forbidden response is returned. Additionally, a new query parameter is introduced in one endpoint to pass the configuration value.

Changes

File(s) Change Summary
src/Digdir.Domain.Dialogporten.Application/…/Authorization/Constants.cs Added constant DisableSystemLabelResetRequiresAdminScope with a message indicating that disabling system label reset requires service owner admin scope.
src/Digdir.Domain.Dialogporten.Application/…/Dialogs/Commands/Update/UpdateDialogCommand.cs,
src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/{DialogActivities/Create/CreateDialogActivityEndpoint.cs, DialogTransmissions/Create/CreateDialogTransmissionEndpoint.cs, Dialogs/Patch/PatchDialogsController.cs, Dialogs/Update/UpdateDialogEndpoint.cs}
Introduced a new boolean property DisableSystemLabelReset in command and request classes, updated endpoint and handler logic to conditionally bypass system label reset based on the property value, and added a query parameter (disableSystemLabelReset) in the Patch endpoint.

Suggested reviewers

  • MagnusSandgren
  • arealmaas

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/Dialogs/Patch/PatchDialogsController.cs (1)

66-72: Update API documentation to include the new parameter.

The new disableSystemLabelReset parameter should be documented in the method's remarks section to inform API consumers about its purpose and behavior.

Apply this diff to update the documentation:

    /// Patches a dialog aggregate with a RFC6902 JSON Patch document. The patch document must be a JSON array of RFC6902 operations.
    /// See [https://tools.ietf.org/html/rfc6902](https://tools.ietf.org/html/rfc6902) for more information.
    ///
    /// Optimistic concurrency control is implemented using the If-Match header. Supply the Revision value from the GetDialog endpoint to ensure that the dialog is not modified/deleted by another request in the meantime.
+   /// 
+   /// The disableSystemLabelReset parameter allows administrators to prevent the system label from being reset during the update.
    /// </remarks>
src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommand.cs (1)

174-177: Consider making UpdateLabel method private.

Since UpdateLabel is only called from within the Handle method, it should be marked as private to better encapsulate the implementation.

-    private void UpdateLabel(DialogEntity dialog)
+    private static void UpdateLabel(DialogEntity dialog)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5adda59 and 736c92b.

📒 Files selected for processing (6)
  • src/Digdir.Domain.Dialogporten.Application/Common/Authorization/Constants.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommand.cs (4 hunks)
  • src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/DialogActivities/Create/CreateDialogActivityEndpoint.cs (2 hunks)
  • src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/DialogTransmissions/Create/CreateDialogTransmissionEndpoint.cs (2 hunks)
  • src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/Dialogs/Patch/PatchDialogsController.cs (2 hunks)
  • src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/Dialogs/Update/UpdateDialogEndpoint.cs (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Dry run deploy apps / Deploy web-api-eu to test
  • GitHub Check: build / build-and-test
🔇 Additional comments (10)
src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/Dialogs/Update/UpdateDialogEndpoint.cs (2)

42-43: LGTM! Command initialization looks good.

The new DisableSystemLabelReset property is correctly initialized with a default value of false, following the same pattern as DisableAltinnEvents.


75-76: LGTM! Property declaration is consistent.

The new property follows the same pattern as DisableAltinnEvents, using the [HideFromDocs] attribute and nullable boolean type.

src/Digdir.Domain.Dialogporten.Application/Common/Authorization/Constants.cs (1)

20-21: LGTM! Clear and consistent error message.

The new constant follows the same pattern as other admin scope requirement messages, providing clear feedback to users.

src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/DialogTransmissions/Create/CreateDialogTransmissionEndpoint.cs (2)

69-70: LGTM! Command initialization looks good.

The new DisableSystemLabelReset property is correctly initialized with a default value of false, following the same pattern as DisableAltinnEvents.


102-103: LGTM! Property declaration is consistent.

The new property follows the same pattern as DisableAltinnEvents, using the [HideFromDocs] attribute and nullable boolean type.

src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/DialogActivities/Create/CreateDialogActivityEndpoint.cs (2)

69-70: LGTM! Command initialization looks good.

The new DisableSystemLabelReset property is correctly initialized with a default value of false, following the same pattern as DisableAltinnEvents.


104-105: LGTM! Property declaration is consistent.

The new property follows the same pattern as DisableAltinnEvents, using the [HideFromDocs] attribute and nullable boolean type.

src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/Dialogs/Patch/PatchDialogsController.cs (1)

92-99: LGTM!

The command initialization correctly handles the new DisableSystemLabelReset property, maintaining backward compatibility with a default value of false.

src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommand.cs (2)

23-34: LGTM!

The new property is well-integrated into the command class, following the existing pattern.


71-74: LGTM!

The permission check correctly enforces that only administrators can disable the system label reset.

@oskogstad oskogstad merged commit a5689f2 into main Feb 20, 2025
23 checks passed
@oskogstad oskogstad deleted the feat/disable-label-reset-on-update branch February 20, 2025 11:20
oskogstad pushed a commit that referenced this pull request Feb 20, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.55.0](v1.54.0...v1.55.0)
(2025-02-20)


### Features

* **webapi:** Add flag for disabling SystemLabel reset
([#1921](#1921))
([a5689f2](a5689f2))


### Bug Fixes

* **webapi:** Add missing 404 status code in activity list swagger
schema ([#1924](#1924))
([8f382cd](8f382cd))
* **webapi:** Add missing status codes in swagger docs for transmissions
endpoints ([#1926](#1926))
([2458d6a](2458d6a))


### Miscellaneous Chores

* **ci:** Releasing NuGet depends on app-deploy
([#1920](#1920))
([37f9990](37f9990))
* **ci:** Use correct project path for NuGet publishing
([#1925](#1925))
([7507187](7507187))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants