fix: adds support for document types named using _id incompatible chars #49
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The problem
Turns out that if you do both of these:
a-zA-Z0-9._-
AI Assist will crash.
Example:
type/with/id/incompatible/slash
The culprit
For each document type, we store instructions in a companion document.
The id for these companion documents is constructed directly from the type name. If the type name has id-incompatible characters, we are gonna have a bad time.
The fix
Ensure the companion document id does not contain illegal characters.
The complication (and workaround)
The current code extracts the type name from the companion document id in the inspector panel, as the document type is used various places.
When we replace illegal characters, we lose information, and cannot get back to the type name (and thus cannot resolve the type).
To work around this, we pass the document type into an existing context (with some type adjustments), so we can access it in the inspector.
Testing
The test studio has been adjusted to include one of these exotic type names & required structure tool changes, so we can ensure this works now.
Example