Auto-enable conneg when mashlib is enabled - #127
Conversation
Mashlib expects .ttl files served as Turtle, but without --conneg the raw JSON-LD is served causing parse errors. Now --mashlib or --mashlib-cdn automatically sets conneg: true. Closes #22
There was a problem hiding this comment.
Pull request overview
This pull request automatically enables content negotiation (conneg) when Mashlib data browser is enabled via --mashlib or --mashlib-cdn flags. This addresses a usability issue where Mashlib would fail with parse errors when trying to read .ttl files that were served as raw JSON-LD instead of being converted to Turtle format through content negotiation.
Changes:
- Auto-enable
conneg: truewhenmashlibormashlibCdnis enabled in configuration loading - Eliminates the need for users to manually specify both
--mashlib-cdn --connegflags - Prevents parse errors in Mashlib that occur when Turtle files are served as JSON-LD
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (config.mashlib || config.mashlibCdn) { | ||
| config.conneg = true; | ||
| } |
There was a problem hiding this comment.
This unconditionally overrides explicit user settings for conneg. If a user explicitly sets --conneg=false, JSS_CONNEG=false, or "conneg": false in their config file, this code will override their choice. The auto-enable logic should only apply when conneg hasn't been explicitly configured by the user. Consider checking if conneg was explicitly set in cliOptions, envConfig, or fileConfig before auto-enabling it, or at minimum only enable it when the merged value is still false (the default).
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
There was a problem hiding this comment.
Thanks for the review. In this case, --mashlib without conneg is a broken combination — mashlib requires Turtle content negotiation to function. Serving .ttl files as raw JSON-LD always causes parse errors.
This is an implicit dependency, similar to how --ssl-cert requires --ssl-key. There's no valid use case for --mashlib --no-conneg, so auto-enabling is the correct behavior.
|
@melvincarvalho I've opened a new pull request, #128, to work on those changes. Once the pull request is ready, I'll request review from you. |
Summary
--mashlibor--mashlib-cdnis enabled, automatically setconneg: true.ttlfiles served as Turtle, but without conneg the raw JSON-LD is served, causing parse errors likeStrange: Error parse_error trying to read your preference fileChange
One check added to
loadConfig()insrc/config.js(5 lines).Test plan
jss start --mashlib-cdnnow serves Turtle without needing explicit--conneg--connegstill works independentlyCloses #22