Skip to content

Commit d05be9a

Browse files
fix: sf connector docs (onyx-dot-app#5171)
* fix: sf connector docs * more sf logs * better logs and new attempt * add fields to error temporarily * fix sf --------- Co-authored-by: Wenxi <wenxi@onyx.app>
1 parent b440f6e commit d05be9a

File tree

4 files changed

+118
-7
lines changed

4 files changed

+118
-7
lines changed

backend/onyx/connectors/salesforce/connector.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ def _full_sync(
438438
) -> GenerateDocumentsOutput:
439439
type_to_processed: dict[str, int] = {}
440440

441-
logger.info("_fetch_from_salesforce starting.")
441+
logger.info("_fetch_from_salesforce starting (full sync).")
442442
if not self._sf_client:
443443
raise RuntimeError("self._sf_client is None!")
444444

@@ -622,7 +622,7 @@ def _delta_sync(
622622
) -> GenerateDocumentsOutput:
623623
type_to_processed: dict[str, int] = {}
624624

625-
logger.info("_fetch_from_salesforce starting.")
625+
logger.info("_fetch_from_salesforce starting (delta sync).")
626626
if not self._sf_client:
627627
raise RuntimeError("self._sf_client is None!")
628628

@@ -936,12 +936,28 @@ def _make_context(
936936

937937
child_types_all = sf_client.get_children_of_sf_type(parent_type)
938938
logger.debug(f"Found {len(child_types_all)} child types for {parent_type}")
939+
logger.debug(f"child types: {child_types_all}")
939940

940941
child_types_working = child_types_all.copy()
941942
if associations_config is not None:
942943
child_types_working = {
943944
k: v for k, v in child_types_all.items() if k in associations_config
944945
}
946+
any_not_found = False
947+
for k in associations_config:
948+
if k not in child_types_working:
949+
any_not_found = True
950+
logger.warning(f"Association {k} not found in {parent_type}")
951+
if any_not_found:
952+
queryable_fields = sf_client.get_queryable_fields_by_type(
953+
parent_type
954+
)
955+
raise RuntimeError(
956+
f"Associations {associations_config} not found in {parent_type} "
957+
"make sure your parent-child associations are in the right order"
958+
# f"with child objects {child_types_all}"
959+
# f" and fields {queryable_fields}"
960+
)
945961

946962
parent_to_child_relationships[parent_type] = set()
947963
parent_to_child_types[parent_type] = set()

web/src/components/Field.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { transformLinkUri } from "@/lib/utils";
3838
import FileInput from "@/app/admin/connectors/[connector]/pages/ConnectorInput/FileInput";
3939
import { DatePicker } from "./ui/datePicker";
4040
import { Textarea, TextareaProps } from "./ui/textarea";
41+
import { RichTextSubtext } from "./RichTextSubtext";
4142
import {
4243
TypedFile,
4344
createTypedFile,
@@ -92,6 +93,18 @@ export function SubLabel({ children }: { children: string | JSX.Element }) {
9293
// Add whitespace-pre-wrap for multiline descriptions (when children is a string with newlines)
9394
const hasNewlines = typeof children === "string" && children.includes("\n");
9495

96+
// If children is a string, use RichTextSubtext to parse and render links
97+
if (typeof children === "string") {
98+
return (
99+
<div className="text-sm text-neutral-600 dark:text-neutral-300 mb-2">
100+
<RichTextSubtext
101+
text={children}
102+
className={hasNewlines ? "whitespace-pre-wrap" : ""}
103+
/>
104+
</div>
105+
);
106+
}
107+
95108
return (
96109
<div
97110
className={`text-sm text-neutral-600 dark:text-neutral-300 mb-2 ${hasNewlines ? "whitespace-pre-wrap" : ""}`}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import React from "react";
2+
3+
interface RichTextSubtextProps {
4+
text: string;
5+
className?: string;
6+
}
7+
8+
/**
9+
* Component that renders text with clickable links.
10+
* Detects URLs in the text and converts them to clickable links.
11+
* Also supports markdown-style links like [text](url).
12+
*/
13+
export function RichTextSubtext({
14+
text,
15+
className = "",
16+
}: RichTextSubtextProps) {
17+
// Function to parse text and create React elements
18+
const parseText = (input: string): React.ReactNode[] => {
19+
const elements: React.ReactNode[] = [];
20+
21+
// Regex to match markdown links [text](url) and plain URLs
22+
const combinedRegex = /(\[([^\]]+)\]\(([^)]+)\))|(https?:\/\/[^\s]+)/g;
23+
24+
let lastIndex = 0;
25+
let match;
26+
let key = 0;
27+
28+
while ((match = combinedRegex.exec(input)) !== null) {
29+
// Add text before the match
30+
if (match.index > lastIndex) {
31+
elements.push(
32+
<span key={`text-${key++}`}>
33+
{input.slice(lastIndex, match.index)}
34+
</span>
35+
);
36+
}
37+
38+
if (match[1]) {
39+
// Markdown-style link [text](url)
40+
const linkText = match[2];
41+
const url = match[3];
42+
elements.push(
43+
<a
44+
key={`link-${key++}`}
45+
href={url}
46+
target="_blank"
47+
rel="noopener noreferrer"
48+
className="text-link hover:text-link-hover underline"
49+
onClick={(e) => e.stopPropagation()}
50+
>
51+
{linkText}
52+
</a>
53+
);
54+
} else if (match[4]) {
55+
// Plain URL
56+
const url = match[4];
57+
elements.push(
58+
<a
59+
key={`link-${key++}`}
60+
href={url}
61+
target="_blank"
62+
rel="noopener noreferrer"
63+
className="text-link hover:text-link-hover underline"
64+
onClick={(e) => e.stopPropagation()}
65+
>
66+
{url}
67+
</a>
68+
);
69+
}
70+
71+
lastIndex = match.index + match[0].length;
72+
}
73+
74+
// Add remaining text after the last match
75+
if (lastIndex < input.length) {
76+
elements.push(
77+
<span key={`text-${key++}`}>{input.slice(lastIndex)}</span>
78+
);
79+
}
80+
81+
return elements;
82+
};
83+
84+
return <div className={className}>{parseText(text)}</div>;
85+
}

web/src/lib/connectors/connectors.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -638,15 +638,12 @@ Example:
638638
"Account": {
639639
"fields": ["Id", "Name", "Industry"],
640640
"associations": {
641-
"Contact": {
642-
"fields": ["Id", "FirstName", "LastName", "Email"],
643-
"associations": {}
644-
}
641+
"Contact": ["Id", "FirstName", "LastName", "Email"]
645642
}
646643
}
647644
}
648645
649-
See our docs for more details.`,
646+
[See our docs](https://docs.onyx.app/connectors/salesforce) for more details.`,
650647
},
651648
],
652649
},

0 commit comments

Comments
 (0)