Skip to content

Add raw option to upload SLD styles as given - #233

Open
Yibbzz wants to merge 1 commit into
camptocamp:masterfrom
Yibbzz:sld-raw-upload
Open

Yibbzz wants to merge 1 commit into
camptocamp:masterfrom
Yibbzz:sld-raw-upload

Conversation

@Yibbzz

@Yibbzz Yibbzz commented Nov 9, 2026

Copy link
Copy Markdown

Why

Without raw=true, GeoServer parses an uploaded SLD and stores its own re-encoding instead of the file: it is reformatted, gets sld: namespace prefixes, and its style name becomes "Default Styler". A style exported from one GeoServer and uploaded to another therefore never matches its source, which breaks keeping styles in version control.

The REST service already sends raw=true for MBStyle uploads. This adds the same option for SLD, opt-in, so the default behaviour is unchanged.

Changes

  • RestService.create_style takes raw: bool = False; for SLD uploads it sends raw=true when set. MBStyle still always does.
  • create_style_from_string and create_style_from_file take raw: bool = False and pass it through. For .zip files it has no effect.
  • Docstrings for both.

Tests

  • New unit tests in tests/test_style.py, using query_param_matcher:

    • raw=true is sent for create_style_from_file(..., raw=True) and create_style_from_string(..., raw=True);
    • nothing is sent by default.

    With the raw=true line removed from RestService.create_style, exactly the two raw tests fail.

  • Full suite: 199 passed (Python 3.14). black and isort are clean.

  • Checked against GeoServer Cloud 3.0.2.1 with a real SLD of 35 lines:

    • with raw=False, the stored file differs from the upload (rewritten);
    • with raw=True, it is byte-for-byte identical.

Without raw=true, GeoServer parses an uploaded SLD and stores its own
re-encoding: the file is reformatted and its style name becomes
"Default Styler", so a style exported from one GeoServer and uploaded to
another no longer matches its source. The REST API already sends
raw=true for MBStyle uploads; this adds an opt-in raw parameter for SLD
to create_style_from_string and create_style_from_file. The default is
unchanged.

This branch has not been deployed

No deployments
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.

1 participant