Skip to content

fix: maintainance able to handle dateRange being invalid #5701

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

akaBilih
Copy link

Added additional check in the model of maintenance.js to avoid an exception when recieving a payload without a date range.

⚠️⚠️⚠️ Since we do not accept all types of pull requests and do not want to waste your time. Please be sure that you have read pull request rules:
https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma

Tick the checkbox if you understand [x]:

  • I have read and understand the pull request rules.

Description

No issue created beforehand

Type of change

Please delete any options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • My code follows the style guidelines of this project
  • I ran ESLint and other linters for modified files
  • I have performed a self-review of my own code and tested it
  • I have commented my code, particularly in hard-to-understand areas (including JSDoc for methods)
  • My changes generates no new warnings
  • My code needed automated testing. I have added them (this is optional task)

Screenshots (if any)

Please do not use any external image service. Instead, just paste in or drag and drop the image here, and it will be uploaded automatically.

Added additional check in the model of maintenance.js to avoid an exception when recieving a payload without a date range.
Copy link
Collaborator

@CommanderStorm CommanderStorm left a comment

Choose a reason for hiding this comment

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

Description
No issue created beforehand

Could you please explain what bug this fixes?
How did you experience it, what are the consequences.

Currently, this looks quite like the usual AI-Spam/Slop we get a lot..

@CommanderStorm CommanderStorm added the question Further information is requested label Mar 21, 2025
@akaBilih
Copy link
Author

Hello,
yes, of course!

I installed autokuma which also has the "kuma-cli" project. I was interested in using it to activate and de-activate maintenances in an automatic maner when the server backs up the docker containers, for which the containers need to be stopped.

To do so, i created a script that will automatically calls the kuma-cli command kuma maintenance add if it detects that a maintenance for the container being backed up doesn't exist, but i was getting an error when creating them with the command.

Since the maintenance subcommand is not extensively documented i had to debug for a while before realising that currently, the socket event that parses the maintenance creation information uses the function jsonToBean to deserialize the information but throws an exception in the case that the maintenance that is being parsed is manually triggered maintenance without a date component. This is caused by the deserializer not checking if obj.dateRange is defined befor trying to access an index inside of it.

The proposed fix just does that: it checks if the dateRange object is defined before it attempts to read it.

Copy link
Collaborator

@CommanderStorm CommanderStorm left a comment

Choose a reason for hiding this comment

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

Fair enough.
So basically, we are skipping input verification on this parameter.

please move this to the input varification for the maintainance or default bean.start_date = null for invalid input.

@CommanderStorm CommanderStorm removed the question Further information is requested label Mar 22, 2025
@CommanderStorm CommanderStorm changed the title Fixed bug in maintenance.js fix: maintainance able to handle dateRange being invalid Mar 22, 2025
@CommanderStorm CommanderStorm added pr:please address review comments this PR needs a bit more work to be mergable A:maintenance Issues or PRs related to the maintenance mode labels Mar 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:maintenance Issues or PRs related to the maintenance mode pr:please address review comments this PR needs a bit more work to be mergable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants