Bug Description
When creating or updating a calendar event with a url field, the server crashes with:
NSInvalidArgumentException - [OC_BuiltinPythonUnicode absoluteString]: unrecognized selector sent to instance
Root Cause
EKEvent.setURL_() expects an NSURL object (from Apple's Foundation framework), but the current code passes a raw Python string directly via PyObjC.
In src/mcp_ical/ical.py:
# Line 99 (create_event)
ekevent.setURL_(new_event.url) # new_event.url is a Python str
# Line 168 (update_event)
existing_ek_event.setURL_(request.url) # request.url is a Python str
When macOS tries to call absoluteString on the Python string (expecting it to be an NSURL), it fails because Python strings don't have that Objective-C method.
Steps to Reproduce
- Start the MCP server
- Create or update an event with a URL field, e.g.:
- Observe the
NSInvalidArgumentException crash
Expected Behavior
The URL should be set on the calendar event without errors.
Fix
Convert the Python string to NSURL before passing to setURL_():
from Foundation import NSURL
# create_event
ekevent.setURL_(NSURL.URLWithString_(new_event.url))
# update_event
existing_ek_event.setURL_(NSURL.URLWithString_(request.url))
Environment
- macOS 15 (Sequoia)
- Python 3.12
- PyObjC (latest)
Bug Description
When creating or updating a calendar event with a
urlfield, the server crashes with:Root Cause
EKEvent.setURL_()expects anNSURLobject (from Apple's Foundation framework), but the current code passes a raw Python string directly via PyObjC.In
src/mcp_ical/ical.py:When macOS tries to call
absoluteStringon the Python string (expecting it to be anNSURL), it fails because Python strings don't have that Objective-C method.Steps to Reproduce
NSInvalidArgumentExceptioncrashExpected Behavior
The URL should be set on the calendar event without errors.
Fix
Convert the Python string to
NSURLbefore passing tosetURL_():Environment