Skip to content

Commit

Permalink
Ensure STA only uses configured netloc (#1883)
Browse files Browse the repository at this point in the history
* Ensure STA only uses configured netloc

Address edgecase where SensorthingsAPI returns a network location inaccessible by pygeoapi by ensuring any backfill requests we make use the configured network location instead of the response network location

* fix flake8
  • Loading branch information
webb-ben authored Dec 19, 2024
1 parent 475c567 commit f181d99
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pygeoapi/provider/sensorthings.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from json.decoder import JSONDecodeError
import logging
from requests import Session
from urllib.parse import urlparse

from pygeoapi.config import get_config
from pygeoapi.provider.base import (
Expand Down Expand Up @@ -209,6 +210,11 @@ def _load(self, offset=0, limit=10, resulttype='results',
try:
LOGGER.debug('Fetching next set of values')
next_ = response['@iot.nextLink']

# Ensure we only use provided network location
next_ = next_.replace(urlparse(next_).netloc,
urlparse(self.data).netloc)

response = self._get_response(next_)
v.extend(response['value'])
except (ProviderConnectionError, KeyError):
Expand Down

0 comments on commit f181d99

Please sign in to comment.