Skip to content

Normalize connection URLs on the read path#1998

Merged
kmcginnes merged 1 commit into
mainfrom
normalize-connection-url-read-path
Jul 23, 2026
Merged

Normalize connection URLs on the read path#1998
kmcginnes merged 1 commit into
mainfrom
normalize-connection-url-read-path

Conversation

@kmcginnes

@kmcginnes kmcginnes commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Description

Follow-up to #1982, which trimmed URL whitespace only on connection-form submit — that never repairs connections already persisted with bad data. This normalizes at the read path instead, so existing connections work without being re-saved.

  • normalizeConnection now strips newlines and surrounding whitespace (in addition to the existing trailing-slash) from url and graphDbUrl. Because it feeds every request and the graph-db-connection-url proxy header, existing bad data is repaired on read.
  • normalizeConnection also tolerates a missing url key. Persisted configs are not schema-validated on read, so a stored connection can lack url despite the compile-time required type; previously this crashed the connection view app-wide via undefined.replace.
  • Exported connection files clean the url too and omit an empty graphDbUrl, so a non-proxy export survives its own import validation.
  • Export is refused with a toast when a connection has no usable URL, and "Save a Copy & Delete" now deletes only when the backup copy was actually written (previously it deleted regardless, losing the connection with no copy).

Out of scope, by design: the connection form (CreateConnection.tsx, being reworked separately), any IndexedDB migration, and Zod-on-read for stored configs.

Validation

  • pnpm checks and full pnpm test pass (all suites green).
  • New tests cover: whitespace/newline stripping and missing-url tolerance in normalizeConnection; clean re-importable export for both non-proxy (graphDbUrl omitted) and proxy connections; export-refused toast; and delete-skipped-when-refused in the save-a-copy flow.

How to read

  1. configuration.ts — the core change: new normalizeUrl helper and its use in normalizeConnection
  2. saveConfigurationToFile.ts — export cleaning + empty-graphDbUrl omission
  3. exportConnection.ts — new guarded export helper returning success
  4. ConnectionDeleteButton.tsx — gate the delete on a successful copy

Related Issues

Check List

  • I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • I have verified pnpm checks passes with no errors.
  • I have verified pnpm test passes with no failures.
  • I have covered new added functionality with unit tests if necessary.
  • I have updated documentation if necessary.

Strip newlines and surrounding whitespace from connection URLs in
normalizeConnection, so existing connections with pasted whitespace/newlines
work without re-saving, including the graph-db-connection-url proxy header.
normalizeConnection also tolerates a missing url key: persisted configs are not
schema-validated on read, so a stored connection can lack url and previously
crashed mergedConfigurationSelector app-wide via undefined.replace.

Exported connection files clean the url too, and omit an empty graphDbUrl so a
non-proxy export survives its own import validation. Export is refused with a
toast when a connection has no usable url; the save-a-copy-then-delete flow now
deletes only when the backup copy was actually written.
@kmcginnes
kmcginnes marked this pull request as ready for review July 23, 2026 22:42
@kmcginnes
kmcginnes merged commit efa48db into main Jul 23, 2026
6 checks passed
@kmcginnes
kmcginnes deleted the normalize-connection-url-read-path branch July 23, 2026 22:43
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.

Connection form accepts spaces and newlines in URL fields

1 participant