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

RenameFiles arg documentation in sonarr model is missing seriesId kwag requirement. #157

Closed
2 tasks done
mymy-dot opened this issue Jul 11, 2023 · 1 comment · Fixed by #160
Closed
2 tasks done
Labels
type/docs Improvements or additions to documentation

Comments

@mymy-dot
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behaviour

On line 53 in the sonarr model, there's the following documentation:

RenameFiles:
    Renames files to the expected naming format.

    Args:
        files (list[int]): List of File IDs to rename.

But this is missing the seriesId, which is required.

This code will fail:

kwargs = {'files': file_ids}
data = sonarr_client.post_command("RenameFiles", **kwargs)

In the events it will show up as: "Error occurred while executing task RenameFiles: Series with ID 0 does not exist"

Changing the code to this solves the error and correctly executes the file rename in sonarr:

kwargs = {'seriesId':my_series['id'],'files': file_ids}
data = sonarr_client.post_command("RenameFiles", **kwargs)

I suspect that this wasn't noticed because in test_sonarr.py the files that are renamed are actually for series ID 0 and that's what the code will default to if the seriesId is missing from the kwargs.

Steps To Reproduce

No response

Expected behaviour

I think it's just a matter of adding seriesId as a requirement for renamefiles to the sonarr model documentation.

Pyarr Version

5.1.0

Python Version

3.11.4

Example Code

No response

Relevant log output

NzbDrone.Core.Datastore.ModelNotFoundException: Series with ID 0 does not exist
  at NzbDrone.Core.Datastore.BasicRepository`1[TModel].Get (System.Int32 id) [0x00021] in C:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Core\Datastore\BasicRepository.cs:85 
  at NzbDrone.Core.Tv.SeriesService.GetSeries (System.Int32 seriesId) [0x00000] in C:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Core\Tv\SeriesService.cs:58 
  at NzbDrone.Core.MediaFiles.RenameEpisodeFileService.Execute (NzbDrone.Core.MediaFiles.Commands.RenameFilesCommand message) [0x00000] in C:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Core\MediaFiles\RenameEpisodeFileService.cs:159 
  at NzbDrone.Core.Messaging.Commands.CommandExecutor.ExecuteCommand[TCommand] (TCommand command, NzbDrone.Core.Messaging.Commands.CommandModel commandModel) [0x000e0] in C:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Core\Messaging\Commands\CommandExecutor.cs:96 
  at (wrapper dynamic-method) System.Object.CallSite.Target(System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,NzbDrone.Core.Messaging.Commands.CommandExecutor,object,NzbDrone.Core.Messaging.Commands.CommandModel)
  at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid3[T0,T1,T2] (System.Runtime.CompilerServices.CallSite site, T0 arg0, T1 arg1, T2 arg2) [0x00035] in <f6dafaadcc284cb8bb8673788981e155>:0 
  at (wrapper dynamic-method) System.Object.CallSite.Target(System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,NzbDrone.Core.Messaging.Commands.CommandExecutor,object,NzbDrone.Core.Messaging.Commands.CommandModel)
  at NzbDrone.Core.Messaging.Commands.CommandExecutor.ExecuteCommands () [0x00027] in C:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Core\Messaging\Commands\CommandExecutor.cs:41

Code of Conduct

  • I agree to follow this project's Code of Conduct
@mymy-dot mymy-dot added the type/bug Something isn't working label Jul 11, 2023
@marksie1988
Copy link
Collaborator

I will update the documentation as this is an option.

Its a difficult one to count for in the tests as the command is posted, but the error doesnt get returned, just the job being scheduled is returned which doesnt help with the current tests.

That said I think I also have a workaround for the tests to get the command once its posted and make sure there isnt an exception.

@marksie1988 marksie1988 added type/docs Improvements or additions to documentation and removed type/bug Something isn't working labels Jul 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/docs Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants