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

[Bug]: UploadW8BenDocumentRequest fails due type errors #226

Open
2 tasks done
palafoxernesto opened this issue Jan 4, 2023 · 0 comments
Open
2 tasks done

[Bug]: UploadW8BenDocumentRequest fails due type errors #226

palafoxernesto opened this issue Jan 4, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@palafoxernesto
Copy link

palafoxernesto commented Jan 4, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When trying to upload a W8BenDocument using UploadW8BenDocumentRequest two typing errors are rised.

The first one is because of type date not converted to string, the other is because of the type IPAddress not converted to string.

Expected Behavior

Date and IPAddress should be converted to string to make them json serializable

SDK Version I encountered this issue in

alpaca-py master

Steps To Reproduce

Currently date and IPAddress attributes are not converted to string. W8BenDocument has 2 date attributes: date and date_of_birth. Which causes this error:

requests.exceptions.InvalidJSONError: Object of type date is not JSON serializable

Fixing the issue described above, an other error is rised:

requests.exceptions.InvalidJSONError: Object of type IPv4Address is not JSON serializable

This other error is again because of the type IPAddress not converted to string.

You can reproduce the error on main branch using a broker_client and this request:

from datetime import datetime, date
from alpaca.broker.requests import UploadW8BenDocumentRequest
from alpaca.broker.models.documents import W8BenDocument, IPv4Address

account_id = "2a87c088-ffb6-472b-a4a3-cd9305c8605c"
document_date = date(2023, 1, 3)
date_of_birth = date(1999, 1,23)
timestamp = datetime.now()
ip_address=IPv4Address(address="189.147.173.150")

broker_client.upload_documents_to_account(
        account_id=account_id,
        document_data=[
            UploadW8BenDocumentRequest(
                content_data=W8BenDocument(
                    country_citizen="Other",
                    date=document_date,
                    date_of_birth=date_of_birth,
                    full_name="Some Name",
                    ip_address=ip_address,
                    permanent_address_city_state="Springfield",
                    permanent_address_country="US",
                    permanent_address_street="742 de Evergreen Terrace",
                    revision="10-2021",
                    signer_full_name="Some Name",
                    timestamp=timestamp,
                    foreign_tax_id="CXXC990123ME2",
                ),
            )
        ],
    )

Filled out the Steps to Reproduce section?

  • I have entered valid steps to reproduce my issue or have attached a minimally reproducible case in code that shows my issue happening; and understand that without this my issue will be flagged as invalid and closed after 30 days.

Anything else?

I've already fixed this, will push and create PR for feedback

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

Successfully merging a pull request may close this issue.

2 participants