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

Fix listing schedules with unassigned users #519

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fr12k
Copy link

@fr12k fr12k commented Aug 6, 2024

Behavior

The schedules_v2_list_schedule_entries.sync function call fails with the following trace.

When a schedule is defined without an associated user then the following error ocuured.

Traceback (most recent call last):
  File "/xxx/src/get_oncall_report_incidentio.py", line 190, in <module>
    main()
  File "/xxx/src/get_oncall_report_incidentio.py", line 99, in main
    resp = schedules_v2_list_schedule_entries.sync(client=api_client, schedule_id=schedule_id, entry_window_start=query_start_time, entry_window_end=query_end_time)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/.venv/lib/python3.11/site-packages/incident_io_client/api/schedules_v2/schedules_v2_list_schedule_entries.py", line 131, in sync
    return sync_detailed(
           ^^^^^^^^^^^^^^
  File "/xxx/.venv/lib/python3.11/site-packages/incident_io_client/api/schedules_v2/schedules_v2_list_schedule_entries.py", line 104, in sync_detailed
    return _build_response(client=client, response=response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/.venv/lib/python3.11/site-packages/incident_io_client/api/schedules_v2/schedules_v2_list_schedule_entries.py", line 66, in _build_response
    parsed=_parse_response(client=client, response=response),
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/.venv/lib/python3.11/site-packages/incident_io_client/api/schedules_v2/schedules_v2_list_schedule_entries.py", line 50, in _parse_response
    response_200 = SchedulesV2ListScheduleEntriesResponseBody.from_dict(response.json())
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/.venv/lib/python3.11/site-packages/incident_io_client/models/schedules_v2_list_schedule_entries_response_body.py", line 93, in from_dict
    schedule_entries = ScheduleEntriesListPayloadV2ResponseBody.from_dict(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/.venv/lib/python3.11/site-packages/incident_io_client/models/schedule_entries_list_payload_v2_response_body.py", line 91, in from_dict
    final_item = ScheduleEntryV2ResponseBody.from_dict(final_item_data)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/.venv/lib/python3.11/site-packages/incident_io_client/models/schedule_entry_v2_response_body.py", line 114, in from_dict
    user = UserV2ResponseBody.from_dict(_user)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/.venv/lib/python3.11/site-packages/incident_io_client/models/user_v2_response_body.py", line 64, in from_dict
    d = src_dict.copy()
        ^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'copy'

Expected Behavior

The schedules_v2_list_schedule_entries.sync function returns the schedules even if there is assigned.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of user data by treating both Unset and None values consistently, ensuring more reliable processing of input data.

Copy link

coderabbitai bot commented Aug 6, 2024

Walkthrough

The recent changes enhance the from_dict method in the schedule_entry_v2_response_body.py file. The update broadens the handling of the _user variable, ensuring that both Unset and None values are treated equivalently. This improvement promotes consistency and robustness in processing input dictionaries, resulting in a more reliable instantiation of the UserV2ResponseBody.

Changes

File Path Change Summary
incident_io_client/models/..._body.py Enhanced from_dict method to treat both _user as Unset and None equivalently, improving consistency.

Poem

🐇 In the code where bunnies play,
A little tweak made bright the day.
If _user hides, be it Unset or none,
A cozy UNSET finds its home.
Hopping forth with checks anew,
Robust and sleek, we’re better too! ✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@fr12k fr12k changed the title Fix schedule user is unset Fix listing schedules with unassigned users Aug 6, 2024
@fr12k
Copy link
Author

fr12k commented Aug 6, 2024

I don't know if the suggested change is a proper fix.
At least it works for us.

Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between df236dd and 245e6f2.

Files selected for processing (1)
  • incident_io_client/models/schedule_entry_v2_response_body.py (1 hunks)
Additional comments not posted (1)
incident_io_client/models/schedule_entry_v2_response_body.py (1)

107-109: LGTM! Ensure consistent handling of None values.

The change ensures that both Unset and None values are treated equivalently, improving robustness.

However, verify the usage of the from_dict method to ensure consistent handling of None values across the codebase.

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.

1 participant