Skip to content

Conversation

@nickhammond
Copy link
Contributor

@nickhammond nickhammond commented May 9, 2025

.delete is a class method and monitor_api_url isn't defined on the class or the config, just on an instance of a monitor. I moved the API URL up to a constant and removed the instance method so that it can be utilized from a class or instance method.

You can see the failing call to delete when you run specs locally with an API key, you'll get:

(app):4:in '<main>': undefined method 'monitor_api_url' for module Cronitor (NoMethodError)

        "#{Cronitor.monitor_api_url}/#{key}",


monitors = opts[:monitors] || [opts]
url = "https://cronitor.io/api/monitors"
url = Cronitor::Monitor::API_URL
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It works in this class method because the string is hardcoded in here.

attr_reader :key, :api_key, :api_version, :env

PING_RETRY_THRESHOLD = 3
API_URL = 'https://cronitor.io/api/monitors'.freeze
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a need to make this configurable? Something for internal testing/usage for example.

"https://cronitor.io/p/#{api_key}/#{key}"
end

def monitor_api_url
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No longer needed since instance and class methods now just utilize the constant.

@nickhammond
Copy link
Contributor Author

Anything else needed here?

@aflanagan
Copy link
Contributor

Hi @nickhammond thanks so much for bringing this up, and my apologies for the slow reply, I had accidentally disabled notifications for this repo. I just released version 5.2.2 which addresses this. However, the intention originally was that .delete should be an instance method not a class method (this aligns with the pattern that the rest of our SDKs follow), so the real bug was that it had been created as a class method. I've fixed that, and will work as documented now. I'm going to close this out, but thank you again for bringing this to my attention!

@aflanagan aflanagan closed this Sep 19, 2025
@nickhammond nickhammond deleted the delete-fix branch September 23, 2025 19:23
@nickhammond
Copy link
Contributor Author

@aflanagan No worries, thanks for releasing the new version with this fix!

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