Skip to content

Fix absolute path issue in create_datastore function#181

Merged
iamtekson merged 4 commits intogicait:masterfrom
maxx-mill:fix-absolute-paths-in-create-datastore
Aug 7, 2025
Merged

Fix absolute path issue in create_datastore function#181
iamtekson merged 4 commits intogicait:masterfrom
maxx-mill:fix-absolute-paths-in-create-datastore

Conversation

@maxx-mill
Copy link
Contributor

Summary

Fixes issue #72 where create_datastore() was embedding absolute file paths into GeoServer's configuration, making the GeoServer instance non-portable across different machines.

Changes

  • Add use_relative_path parameter (default True) to create_datastore function
  • Convert absolute paths to relative paths using data/workspace/filename format
  • Maintain backward compatibility with existing relative paths and HTTP URLs
  • Add test script to demonstrate path conversion functionality

Technical Details

When use_relative_path=True (default), absolute file paths are converted to relative paths like data/workspace/filename.shp, making GeoServer configurations portable across different machines.

Testing

  • Added tests/test_path_fix.py to demonstrate the path conversion functionality
  • Tested with various path formats (Windows, Unix, relative, HTTP URLs)
  • Verified backward compatibility with existing functionality

Breaking Changes

None - this is a backward-compatible enhancement with a new optional parameter.

- Add use_relative_path parameter (default True) to create_datastore
- Convert absolute paths to relative paths using data/workspace/filename format
- Maintain backward compatibility with existing relative paths and HTTP URLs
- Add test script to demonstrate path conversion functionality
- Fixes issue gicait#72 where absolute paths made GeoServer non-portable

The fix ensures that when use_relative_path=True (default), absolute file paths
are converted to relative paths like 'data/workspace/filename.shp', making
GeoServer configurations portable across different machines.
@iboates
Copy link
Collaborator

iboates commented Aug 5, 2025

I agree that it is better to not modify the paths at all, but it could be a breaking change if the previous default behaviour was to convert to absolute paths, since after a package upgrade it would change. While counterintuitive, it might be safer for backwards comaptibility to make the parameter called force_absolute_path, defaulted to True. What do you think @iamtekson?

Also, the test needs to use assert statements so that the test & deployment pipeline can pick up if they are passing or not, currently it will always "pass" because there is no fail condition.

@maxx-mill
Copy link
Contributor Author

thank you for the feedback @iboates I will use that logic in my test cases

@iamtekson
Copy link
Collaborator

Yes, I agree with @iboates. Either we can set use_relative_path=False or force_absolute_path=True by default. Otherwise this change will break the workflow of previous users.

maxx-mill and others added 3 commits August 7, 2025 09:16
… tests

- Rename use_relative_path to force_absolute_path (default True) for backward compatibility
- Update logic to use not force_absolute_path for path conversion
- Add comprehensive test cases with proper assert statements
- Ensure tests will fail if functionality doesn't work correctly
- Maintain backward compatibility as suggested by @iboates and @iamtekson
…ub.com/maxx-mill/geoserver-rest into fix-absolute-paths-in-create-datastore

Merge remote changes to sync branch
.
Copy link
Collaborator

@iamtekson iamtekson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @maxx-mill for your contribution.

@iamtekson iamtekson merged commit 561e2e5 into gicait:master Aug 7, 2025
0 of 5 checks passed
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.

3 participants