Skip to content

Feature/http to https #72

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 4 commits into
base: main
Choose a base branch
from
Open

Feature/http to https #72

wants to merge 4 commits into from

Conversation

ryanaguilar
Copy link

ugly hack to change any urls in the api metadata from http to https. Addresses issue in Boston in which the earthbeam dag is failing to get the dependencies endpoint while trying to load MAP assessment data.

Changes to existing files:

  • api.py : adds an if statement in two places to check for 'http'.

Tests and QC done:

  • tested on Boston 2024 'sandbox' ODS

@ryanaguilar ryanaguilar requested a review from tomreitz April 18, 2025 15:54
@tomreitz
Copy link
Collaborator

Hey @ryanaguilar, thanks for this PR. I'm thinking about the approach here... rather than forcing any http URL to https, could we only do that if a specified http URL is unreachable? Specifically here, the except clause could swap http for https (and maybe vice-versa?) and try again... something like

        try:
            self.logger.debug("fetching base_url...")
            api_base = requests.get(self.config["base_url"],
                                    verify=self.lightbeam.config["connection"]["verify_ssl"])
        except Exception as e:
            try:
                swapped_base_url = self.config["base_url"]
                if "http://" in swapped_base_url: swapped_base_url = swapped_base_url.replace("http://", "https://")
                else: swapped_base_url = swapped_base_url.replace("https://", "http://")
                api_base = requests.get(swapped_base_url ,
                                    verify=self.lightbeam.config["connection"]["verify_ssl"])
            except Exception as e:
                self.logger.critical("could not connect to {0} ({1})".format(self.config["base_url"], str(e)))

(And similarly in load_swagger_docs().) Let me know what you think of this.

@ryanaguilar
Copy link
Author

@tomreitz I realized that this issue cropped up for the swagger urls as well. I guess I could add the same code here and here, but it feels like it's getting cluttered by adding the same code over and over. Is there a better way to do this or should I just keep it simple and add the code in where necessary?

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