From 611106081e4687e9ae5b72cc62d7d76d86ac6ae1 Mon Sep 17 00:00:00 2001 From: Martin Lehmann Date: Fri, 20 Sep 2024 11:10:23 +0200 Subject: [PATCH] fix: Fix comparison in Docker under random UID --- Dockerfile | 9 ++++----- capella_model_explorer/backend/explorer.py | 3 ++- capella_model_explorer/backend/model_diff.py | 2 +- frontend/src/views/ModelComparisonView.jsx | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5ab6980..ee07d1f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,8 +39,6 @@ EXPOSE 8000 COPY ./templates /views -# Cache directory has to be writable -RUN chmod -R 777 /home ENV HOME=/home COPY entrypoint.sh /entrypoint.sh @@ -53,10 +51,11 @@ ENV MODE=production COPY frontend/fetch-version.py ./frontend/ RUN python frontend/fetch-version.py -# Run as non-root user per default -USER 1000 - # Pre-install npm dependencies for context diagrams RUN python -c "from capellambse_context_diagrams import _elkjs; _elkjs._install_required_npm_pkg_versions()" +# Run as non-root user per default +RUN chmod -R 777 /home +USER 1000 + ENTRYPOINT ["/entrypoint.sh"] diff --git a/capella_model_explorer/backend/explorer.py b/capella_model_explorer/backend/explorer.py index 954fd35..a2769e0 100644 --- a/capella_model_explorer/backend/explorer.py +++ b/capella_model_explorer/backend/explorer.py @@ -296,6 +296,7 @@ async def post_compare(commit_range: CommitRange): self.diff["lookup"] = create_diff_lookup(self.diff["objects"]) return {"success": True} except Exception as e: + LOGGER.exception("Failed to compare versions") return {"success": False, "error": str(e)} @self.router.post("/api/object-diff") @@ -375,5 +376,5 @@ def create_diff_lookup(data, lookup=None): if obj["children"]: create_diff_lookup(obj["children"], lookup) except Exception: - pass + LOGGER.exception("Cannot create diff lookup") return lookup diff --git a/capella_model_explorer/backend/model_diff.py b/capella_model_explorer/backend/model_diff.py index a569578..03d2b79 100644 --- a/capella_model_explorer/backend/model_diff.py +++ b/capella_model_explorer/backend/model_diff.py @@ -267,7 +267,7 @@ def compare_objects( "attributes": attributes, "children": children, } - return None + return {} def _handle_attribute_property(attr, old_object, new_object, attributes): diff --git a/frontend/src/views/ModelComparisonView.jsx b/frontend/src/views/ModelComparisonView.jsx index 44515ca..05a1929 100644 --- a/frontend/src/views/ModelComparisonView.jsx +++ b/frontend/src/views/ModelComparisonView.jsx @@ -113,7 +113,7 @@ export const ModelComparisonView = ({ endpoint }) => { modelDiff.objects && Object.keys(modelDiff.objects).map( (layer) => - modelDiff.objects[layer] && ( + Object.keys(modelDiff.objects[layer]).length > 0 && (