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

Don't crash if icloud account/phone can't be inferred #3

Open
hyfen opened this issue Mar 16, 2022 · 4 comments
Open

Don't crash if icloud account/phone can't be inferred #3

hyfen opened this issue Mar 16, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@hyfen
Copy link
Member

hyfen commented Mar 16, 2022

The extractor uses the LocalContacts module to try and infer information about a user's icloud account and phone number (via local Address Book sqlite dbs). If these details can't be found and no options are passed in manually (via my_phone_number setting, etc), the extractor should raise an exception instead of crashing.

This was encountered by @wongjustin99 in #chronicle-etl/33:

Beginning job
/Users/goose/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/chronicle-imessage-0.2.3/lib/chronicle/imessage/imessage_extractor.rb:61:in `load_my_phone_contact': undefined method `fetch' for nil:NilClass (NoMethodError)

          phone_number: @config.my_phone_number || local_contacts.my_phone_contact.fetch(:phone_number),
                                                                                  ^^^^^^
        from /Users/goose/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/chronicle-imessage-0.2.3/lib/chronicle/imessage/imessage_extractor.rb:51:in `prepare_data'
@hyfen
Copy link
Member Author

hyfen commented Mar 16, 2022

@wongjustin99, I'm using the local address book directory (~/Library/Application Support/AddressBook) to try and guess a user's phone number (so that a message's actor can be set properly) and it's hard to know what's typical in accounts that aren't mine.

If you open Contacts.app, do you have an entry at the top for yourself? Does it have a phone number associated with it?

This is what mine looks like:
image

@hyfen hyfen closed this as completed in 02e1785 Mar 16, 2022
@hyfen hyfen reopened this Mar 16, 2022
@wongjustin99
Copy link

I had an empty one for myself - probably since I use contacts synced to an external service. I clicked "Make this my Card" and now I have some phone numbers there.

however, I still see the same error and stacktrace.

I have 10+ numbers, but it appears you have just one. Could that be contributing?

image

@hyfen
Copy link
Member Author

hyfen commented Mar 17, 2022

I pushed updates for chronicle-imessage and chronicle-etl that at least prevent the full crash. You can try again with:

gem install chronicle-etl -v 0.4.4
gem install chronicle-imessage -v 0.2.5
chronicle-etl -e imessage -t imessage --limit 10

I suspect it won't work because #4 isn't handled yet. But you can always pass in the missing information manually:
chronicle-etl -e imessage -t imessage --limit 10 --extractor-opts my_phone_number:123-1234-1234 my_name:foo

The general problem is that the local iMessage sqlite database only contains the identifiers of participants, not your own number. Your iCloud account (for setting the sender of iMessages) is easy to figure out but not your phone number (for setting the sender of SMS). I might consider adding an option for users who don't care about sending the sender field.

Regarding your 10+ numbers, that's another thing I'll have to figure out with some sqlite reverse engineering but I have a feeling it might not be possible to correctly guess which is the sender because I don't see a concept of a default phone number in iCloud contacts.

@wongjustin99
Copy link

I didn't need to manually pass that option in. Actually seems to be working now! Thanks so much for the help.

Now that I have this set up, this might be a conversation for somewhere else besides this issue - but how are you using these plugins? Are they piped into something else for viewing/analysis? Or do you have any ideas you were planning to flesh out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants