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

_:hammer_and_wrench: Refactor suggestion_ #15

Closed
farmisen opened this issue Feb 21, 2025 · 1 comment
Closed

_:hammer_and_wrench: Refactor suggestion_ #15

farmisen opened this issue Feb 21, 2025 · 1 comment

Comments

@farmisen
Copy link
Owner

          _:hammer_and_wrench: Refactor suggestion_

Add input validation for ACL values.

The method should validate that the ACL values are either 'public-read' or 'private' before making the request.

Apply this diff to add input validation:

     async def update_acl(
         self, updates: List[dict[str, str]]
     ) -> UpdateACLResponse:
         """Update ACL settings for one or more files asynchronously.
 
         Args:
             updates: List of update objects containing either:
                     - fileKey and acl
                     - customId and acl
                     where acl can be 'public-read' or 'private'
 
         Returns:
             UpdateACLResponse: Response containing update results
         """
+        valid_acls = {'public-read', 'private'}
+        for update in updates:
+            if 'acl' not in update or update['acl'] not in valid_acls:
+                raise ValueError("ACL must be either 'public-read' or 'private'")
         result = await self._request(
             "POST", "/v6/updateACL", {"updates": updates}
         )
         return UpdateACLResponse(**result)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    async def update_acl(
        self, updates: List[dict[str, str]]
    ) -> UpdateACLResponse:
        """Update ACL settings for one or more files asynchronously.

        Args:
            updates: List of update objects containing either:
                    - fileKey and acl
                    - customId and acl
                    where acl can be 'public-read' or 'private'

        Returns:
            UpdateACLResponse: Response containing update results
        """
        valid_acls = {'public-read', 'private'}
        for update in updates:
            if 'acl' not in update or update['acl'] not in valid_acls:
                raise ValueError("ACL must be either 'public-read' or 'private'")
        result = await self._request(
            "POST", "/v6/updateACL", {"updates": updates}
        )
        return UpdateACLResponse(**result)

Originally posted by @coderabbitai[bot] in #13 (comment)

@farmisen
Copy link
Owner Author

implemented part of #13

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

No branches or pull requests

1 participant