Skip to content

LocalDevDestinationClient resolves mocks/ path relative to venv package directory instead of project root #46

@OhItsLena

Description

@OhItsLena

Describe the Bug

When the application runs inside a Python virtual environment, LocalDevDestinationClient resolves the mocks/destination.json path relative to the SDK's own package directory inside the venv instead of the project root. The documentation states the file should be read from the project root.

I had a look at LocalDevClientBase.__init__ and noticed the path is derived by navigating up three levels from __file__:

repo_root = os.path.abspath(
    os.path.join(os.path.dirname(__file__), "..", "..", "..")
)

This appears to work when running from a source checkout (where the file sits three levels deep from the project root), but when installed into a venv the package lands at .venv/lib/python3.13/site-packages/sap_cloud_sdk/destination/, so three levels up gives .venv/lib/python3.13/ instead of the project root.

Using os.getcwd() instead would likely fix this, as it resolves to wherever the application is launched from regardless of install location — but you may have other considerations I'm not aware of.

Steps to Reproduce

  1. Create a project with mocks/destination.json at the root.
  2. Set up a Python virtual environment and install sap_cloud_sdk into it.
  3. Run the following:
    from sap_cloud_sdk.destination import create_client
    client = create_client(instance="destination-service")
    print(client._file_path)
    dest = client.get_instance_destination("my-destination")
    print(dest)
  4. Observe that _file_path points inside the venv and get_instance_destination() returns None.

Expected Behavior

_file_path should resolve to <project-root>/mocks/destination.json and get_instance_destination() should return the destination defined in that file.

Screenshots

No response

Used Versions

  • Python version via python --version: 3.13.11
  • SAP Cloud SDK for Python version: 0.6.0
  • Framework version (if applicable, e.g., Flask, FastAPI): N/A
Installed packages via pip list or uv pip list
Package                                           Version
------------------------------------------------- ------------
a2a-sdk                                           0.3.22
aiohappyeyeballs                                  2.6.1
aiohttp                                           3.13.5
aiomysql                                          0.3.2
aiosignal                                         1.4.0
aiosqlite                                         0.22.1
alembic                                           1.18.4
annotated-doc                                     0.0.4
annotated-types                                   0.7.0
anthropic                                         0.91.0
anyio                                             4.13.0
application-foundation-sdk-python                 1.6.4
argon2-cffi                                       25.1.0
argon2-cffi-bindings                              25.1.0
asgiref                                           3.11.1
asyncpg                                           0.31.0
attrs                                             26.1.0
blinker                                           1.9.0
cachetools                                        6.2.6
certifi                                           2026.2.25
cffi                                              2.0.0
charset-normalizer                                3.4.7
click                                             8.3.1
cloudpickle                                       3.1.2
colorama                                          0.4.6
contourpy                                         1.3.3
cryptography                                      46.0.7
cuid                                              0.4
cycler                                            0.12.1
databricks-sdk                                    0.102.0
debugpy                                           1.8.11
Deprecated                                        1.3.1
distro                                            1.9.0
docker                                            7.1.0
docstring_parser                                  0.17.0
fastapi                                           0.135.3
fastuuid                                          0.14.0
filelock                                          3.25.2
Flask                                             3.1.3
flask-cors                                        6.0.2
fonttools                                         4.62.1
frozenlist                                        1.8.0
fsspec                                            2026.3.0
gitdb                                             4.0.12
GitPython                                         3.1.46
google-api-core                                   2.30.2
google-auth                                       2.49.1
googleapis-common-protos                          1.74.0
graphene                                          3.4.3
graphql-core                                      3.2.8
graphql-relay                                     3.2.0
greenlet                                          3.3.2
grpcio                                            1.80.0
grpcio-reflection                                 1.80.0
grpcio-tools                                      1.80.0
gunicorn                                          23.0.0
h11                                               0.16.0
hatchling                                         1.27.0
hf-xet                                            1.4.3
httpcore                                          1.0.9
httpx                                             0.28.1
httpx-sse                                         0.4.3
huey                                              2.6.0
huggingface_hub                                   1.9.1
idna                                              3.11
importlib_metadata                                8.7.1
inflection                                        0.5.1
itsdangerous                                      2.2.0
Jinja2                                            3.1.6
jiter                                             0.13.0
joblib                                            1.5.3
jsonpatch                                         1.33
jsonpointer                                       3.1.1
jsonschema                                        4.26.0
jsonschema-specifications                         2025.9.1
kiwisolver                                        1.5.0
langchain                                         1.2.15
langchain-core                                    1.2.15
langchain-litellm                                 0.3.5
langgraph                                         1.1.6
langgraph-checkpoint                              4.0.1
langgraph-prebuilt                                1.0.9
langgraph-sdk                                     0.3.13
langsmith                                         0.7.26
litellm                                           1.81.0
Mako                                              1.3.10
markdown-it-py                                    4.0.0
MarkupSafe                                        3.0.3
matplotlib                                        3.10.8
mdurl                                             0.1.2
minio                                             7.2.20
mlflow                                            3.8.1
mlflow-skinny                                     3.8.1
mlflow-tracing                                    3.8.1
multidict                                         6.7.1
numpy                                             2.4.4
oauthlib                                          3.3.1
openai                                            2.30.0
opentelemetry-api                                 1.38.0
opentelemetry-exporter-otlp-proto-common          1.38.0
opentelemetry-exporter-otlp-proto-grpc            1.38.0
opentelemetry-exporter-otlp-proto-http            1.38.0
opentelemetry-instrumentation                     0.59b0
opentelemetry-instrumentation-agno                0.53.3
opentelemetry-instrumentation-alephalpha          0.53.3
opentelemetry-instrumentation-anthropic           0.53.3
opentelemetry-instrumentation-asgi                0.59b0
opentelemetry-instrumentation-bedrock             0.53.3
opentelemetry-instrumentation-chromadb            0.53.3
opentelemetry-instrumentation-cohere              0.53.3
opentelemetry-instrumentation-crewai              0.53.3
opentelemetry-instrumentation-google-generativeai 0.53.3
opentelemetry-instrumentation-groq                0.53.3
opentelemetry-instrumentation-haystack            0.53.3
opentelemetry-instrumentation-lancedb             0.53.3
opentelemetry-instrumentation-langchain           0.53.3
opentelemetry-instrumentation-llamaindex          0.53.3
opentelemetry-instrumentation-logging             0.59b0
opentelemetry-instrumentation-marqo               0.53.3
opentelemetry-instrumentation-mcp                 0.53.3
opentelemetry-instrumentation-milvus              0.53.3
opentelemetry-instrumentation-mistralai           0.53.3
opentelemetry-instrumentation-ollama              0.53.3
opentelemetry-instrumentation-openai              0.53.3
opentelemetry-instrumentation-openai-agents       0.53.3
opentelemetry-instrumentation-pinecone            0.53.3
opentelemetry-instrumentation-qdrant              0.53.3
opentelemetry-instrumentation-redis               0.59b0
opentelemetry-instrumentation-replicate           0.53.3
opentelemetry-instrumentation-requests            0.59b0
opentelemetry-instrumentation-sagemaker           0.53.3
opentelemetry-instrumentation-sqlalchemy          0.59b0
opentelemetry-instrumentation-starlette           0.59b0
opentelemetry-instrumentation-threading           0.59b0
opentelemetry-instrumentation-together            0.53.3
opentelemetry-instrumentation-transformers        0.53.3
opentelemetry-instrumentation-urllib3             0.59b0
opentelemetry-instrumentation-vertexai            0.53.3
opentelemetry-instrumentation-voyageai            0.53.3
opentelemetry-instrumentation-watsonx             0.53.3
opentelemetry-instrumentation-weaviate            0.53.3
opentelemetry-instrumentation-writer              0.53.3
opentelemetry-processor-baggage                   0.61b0
opentelemetry-proto                               1.38.0
opentelemetry-sdk                                 1.38.0
opentelemetry-semantic-conventions                0.59b0
opentelemetry-semantic-conventions-ai             0.4.16
opentelemetry-util-http                           0.59b0
orjson                                            3.11.8
ormsgpack                                         1.12.2
packaging                                         25.0
pandas                                            2.3.3
pathspec                                          1.0.4
pillow                                            12.2.0
pip                                               25.3
pluggy                                            1.6.0
propcache                                         0.4.1
proto-plus                                        1.27.2
protobuf                                          6.33.6
pyarrow                                           22.0.0
pyasn1                                            0.6.3
pyasn1_modules                                    0.4.2
pycparser                                         3.0
pycryptodome                                      3.23.0
pydantic                                          2.12.5
pydantic_core                                     2.41.5
Pygments                                          2.20.0
PyJWT                                             2.10.1
PyMySQL                                           1.1.2
pyparsing                                         3.3.2
python-dateutil                                   2.9.0.post0
python-dotenv                                     1.2.1
pytz                                              2026.1.post1
PyYAML                                            6.0.3
referencing                                       0.37.0
regex                                             2026.4.4
requests                                          2.31.0
requests-oauthlib                                 2.0.0
requests-toolbelt                                 1.0.0
rich                                              14.2.0
rpds-py                                           0.30.0
sap-cloud-sdk                                     0.6.0
scikit-learn                                      1.8.0
scipy                                             1.17.1
setuptools                                        80.9.0
shellingham                                       1.5.4
six                                               1.17.0
smmap                                             5.0.3
sniffio                                           1.3.1
SQLAlchemy                                        2.0.49
sqlparse                                          0.5.5
sse-starlette                                     3.3.4
starlette                                         1.0.0
tenacity                                          9.1.4
testcontainers                                    4.14.2
threadpoolctl                                     3.6.0
tiktoken                                          0.12.0
tokenizers                                        0.22.2
tqdm                                              4.67.3
traceloop-sdk                                     0.52.6
trove-classifiers                                 2026.1.14.14
typer                                             0.24.1
typing_extensions                                 4.15.0
typing-inspection                                 0.4.2
tzdata                                            2026.1
urllib3                                           2.6.3
uuid_utils                                        0.14.1
uvicorn                                           0.40.0
Werkzeug                                          3.1.8
wrapt                                             1.17.3
xxhash                                            3.6.0
yarl                                              1.23.0
zipp                                              3.23.0
zstandard                                         0.25.0

Code Examples

Reproduction:

from sap_cloud_sdk.destination import create_client

client = create_client(instance="destination-service")
print(client._file_path)
# Prints: /path/to/project/.venv/lib/python3.13/mocks/destination.json

dest = client.get_instance_destination("my-destination")
print(dest)
# Prints: None

Workaround (patching the private attribute):

import os
from sap_cloud_sdk.destination import create_client, LocalDevDestinationClient

client = create_client(instance="destination-service")
if isinstance(client, LocalDevDestinationClient):
    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    client._file_path = os.path.join(root, "mocks", "destination.json")

Stack Trace

No exception is raised. get_instance_destination() silently returns None.

Log File

Log file
Local mock mode active: using LocalDevDestinationClient backed by mocks/destination.json. This is intended for local development only and must not be used in production.

Note: the log message shows the relative path mocks/destination.json but the client actually resolves it to .venv/lib/python3.13/mocks/destination.json.

Affected Development Phase

Development

Impact

Impaired

Timeline

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions