Repository navigation
Feat/check details #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2352bfa
feat: keep what a validation found in the connection's health
grokify 9eb2d40
test: cover validation details, their limits and storage
grokify 80b1c37
docs: describe validation details
grokify 6370180
docs(release): add v0.7.0 changelog and release notes
grokify 24f45a8
fix(service): remove directional formatting characters from details
grokify feffe81
test(service): cover directional characters and details after reconnect
grokify f29a40c
docs(release): add the directional character fix to v0.7.0
grokify File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # v0.7.0 | ||
|
|
||
| **Release Date:** 2026-11-06 | ||
|
|
||
| ## Highlights | ||
|
|
||
| - **A connection shows what it reaches.** A provider's validation can | ||
| return `Details`, such as the sites or projects the credential can read. | ||
| The service shortens them (up to 8 labelled lists of up to 25 values, | ||
| with `More` counting the rest, control and directional formatting | ||
| characters such as U+202E removed, and long values cut) and keeps them in `Health.Details` after each successful check. A | ||
| failed check keeps the last ones, so an interface can show what the | ||
| connection reached when it last worked. | ||
|
|
||
| The release adds no breaking change. Stores keep health as one value, so | ||
| existing records read as before, with no details until their next check. | ||
|
|
||
| ## Upgrading | ||
|
|
||
| Nothing is required. Providers that want to show what a credential reaches | ||
| set `provider.Result.Details`; they must never put a secret in them. | ||
|
|
||
| ## Dependencies | ||
|
|
||
| - `modernc.org/sqlite` 1.61.1 and `github.com/jackc/pgx/v5` 5.12.0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| package service | ||
|
|
||
| import ( | ||
| "strings" | ||
| "unicode" | ||
| "unicode/utf8" | ||
|
|
||
| cf "github.com/plexusone/connectforge" | ||
| "github.com/plexusone/connectforge/provider" | ||
| ) | ||
|
|
||
| // Limits on what a validation's details keep, so a provider that lists | ||
| // thousands of sites still stores and shows a short summary. | ||
| const ( | ||
| maxDetails = 8 | ||
| maxDetailValues = 25 | ||
| maxLabelLen = 64 | ||
| maxValueLen = 200 | ||
| ) | ||
|
|
||
| // details returns a provider's details shortened for storage and display: | ||
| // at most maxDetails, each with at most maxDetailValues values, labels and | ||
| // values cut to length, and control and directional formatting characters | ||
| // removed. A detail with no | ||
| // label is dropped. More counts the values left out. | ||
| func details(in []provider.Detail) []cf.Detail { | ||
| var out []cf.Detail | ||
| for _, d := range in { | ||
| label := clip(d.Label, maxLabelLen) | ||
| if label == "" { | ||
| continue | ||
| } | ||
| if len(out) == maxDetails { | ||
| break | ||
| } | ||
| cd := cf.Detail{Label: label} | ||
| for _, v := range d.Values { | ||
| v = clip(v, maxValueLen) | ||
| if v == "" { | ||
| continue | ||
| } | ||
| if len(cd.Values) == maxDetailValues { | ||
| cd.More++ | ||
| continue | ||
| } | ||
| cd.Values = append(cd.Values, v) | ||
| } | ||
| out = append(out, cd) | ||
| } | ||
| return out | ||
| } | ||
|
|
||
| // clip removes control characters, directional formatting characters and | ||
| // surrounding space from s, and cuts it to at most n bytes on a rune | ||
| // boundary, marking a cut with an ellipsis. Directional overrides and | ||
| // isolates, such as U+202E, would let a provider's text display reordered | ||
| // and mislead the person reading it. | ||
| func clip(s string, n int) string { | ||
| s = strings.TrimSpace(strings.Map(func(r rune) rune { | ||
| if unicode.IsControl(r) || unicode.Is(unicode.Bidi_Control, r) { | ||
| return -1 | ||
| } | ||
| return r | ||
| }, s)) | ||
| if len(s) <= n { | ||
| return s | ||
| } | ||
| cut := n - len("…") | ||
| for cut > 0 && !utf8.RuneStart(s[cut]) { | ||
| cut-- | ||
| } | ||
| return s[:cut] + "…" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| package service | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/plexusone/connectforge/provider" | ||
| ) | ||
|
|
||
| func TestDetailsAreShortened(t *testing.T) { | ||
| var many []string | ||
| for i := range 30 { | ||
| many = append(many, fmt.Sprintf("site-%d.example.com", i)) | ||
| } | ||
| in := []provider.Detail{ | ||
| {Label: " Sites\n", Values: many}, | ||
| {Label: "", Values: []string{"dropped: no label"}}, | ||
| {Label: "Long", Values: []string{strings.Repeat("é", 300), " ", "tab\there"}}, | ||
| } | ||
| for i := range 10 { | ||
| in = append(in, provider.Detail{Label: fmt.Sprintf("extra %d", i)}) | ||
| } | ||
| got := details(in) | ||
| if len(got) != maxDetails { | ||
| t.Fatalf("details = %d, want %d", len(got), maxDetails) | ||
| } | ||
| if got[0].Label != "Sites" || len(got[0].Values) != maxDetailValues || got[0].More != 5 { | ||
| t.Errorf("sites = %q, %d values, more %d", got[0].Label, len(got[0].Values), got[0].More) | ||
| } | ||
| long := got[1] | ||
| if long.Label != "Long" || len(long.Values) != 2 { | ||
| t.Fatalf("long = %+v", long) | ||
| } | ||
| if v := long.Values[0]; len(v) > maxValueLen || !strings.HasSuffix(v, "…") || !strings.HasPrefix(v, "é") { | ||
| t.Errorf("a long value was not cut on a rune boundary: %d bytes", len(v)) | ||
| } | ||
| if long.Values[1] != "tabhere" { | ||
| t.Errorf("control characters kept: %q", long.Values[1]) | ||
| } | ||
| // Directional overrides and isolates are removed, so a value cannot | ||
| // display reordered. | ||
| bidi := details([]provider.Detail{{Label: "Sites\u202e", Values: []string{"evil\u202egnp.exe", "\u2066a\u2069\u200fb\u061c"}}}) | ||
| if bidi[0].Label != "Sites" || bidi[0].Values[0] != "evilgnp.exe" || bidi[0].Values[1] != "ab" { | ||
| t.Errorf("directional characters kept: %+v", bidi) | ||
| } | ||
| if details(nil) != nil { | ||
| t.Error("no details gave a non-nil slice") | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: plexusone/connectforge
Length of output: 19878
Script executed:
Repository: plexusone/connectforge
Length of output: 5546
Web query:
Unicode bidirectional algorithm reordering Arabic Hebrew Latin letters without directional formatting characters isolate text internal reordering UAX 9Result:
Narrow the bidirectional-display claim.
The filter retains Hebrew and Arabic letters. A renderer can reorder text that mixes these letters with Latin text, even without directional formatting characters. The current wording gives consumers a false guarantee.
Suggested fix
Regenerate
CHANGELOG.mdwith the corrected description.Committable suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, fixed in c492d5e. Removing the formatting characters stops overrides and isolates from reordering a value, but mixed right-to-left and left-to-right text can still display in a different order. The entry now says only what is removed, and
CHANGELOG.mdis regenerated.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Analysis chain
Script executed:
Length of output: 4752
Script executed:
Length of output: 3742
@grokifyThanks for the fix. Commitc492d5eremoves the claim from both changelogs.The checked-out revision is still
f29a40c, so I could not verify the fix on the PR head. Please retry the check against the updated PR head.If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
You are interacting with an AI system.