forked from yazanghayad/SWEO
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-jsx-errors.py
More file actions
181 lines (145 loc) · 7.66 KB
/
Copy pathfix-jsx-errors.py
File metadata and controls
181 lines (145 loc) · 7.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/usr/bin/env python3
"""Fix JSX parse errors in landing page files.
Each fix targets the exact error position from the build log.
The approach: for each known error file+line+col, extract the problematic
text and apply the appropriate fix.
"""
import os
import re
BASE = '/workspaces/chat/src/app/(landing)'
# ============================================================
# Helper: apply a text replacement at a specific position in a file
# ============================================================
def fix_file(rel_path, replacements):
"""Apply text replacements to a file.
rel_path: path relative to BASE (e.g., 'help/en/articles/.../page.tsx')
replacements: list of (old_text, new_text) tuples, applied in order
"""
full_path = os.path.join(BASE, rel_path)
with open(full_path, 'r', encoding='utf-8') as f:
content = f.read()
original = content
for old_text, new_text in replacements:
if old_text not in content:
print(f" WARNING: '{old_text[:60]}...' not found in {rel_path}")
continue
content = content.replace(old_text, new_text, 1)
if content != original:
with open(full_path, 'w', encoding='utf-8') as f:
f.write(content)
print(f" FIXED: {rel_path} ({len(replacements)} replacements)")
else:
print(f" UNCHANGED: {rel_path}")
# ============================================================
# Fix each file with known errors
# ============================================================
# 1. help/en/articles/10614191 - Unescaped > in "Apps and integrations > APIs > Conversations API"
fix_file('help/en/articles/10614191-fin-for-zendesk-messaging-setup/page.tsx', [
('> <b>APIs</b> > <b>Conversations API', '> <b>APIs</b> > <b>Conversations API'),
])
# 2. help/en/articles/10614196 - Unescaped { in JSON code block
fix_file('help/en/articles/10614196-fin-messenger-zendesk-setup/page.tsx', [
('<pre>{<br /> "id": "457"', '<pre>{"{"}<br /> "id": "457"'),
])
# 3. help/en/articles/10644329 - Unescaped { in template variables
fix_file('help/en/articles/10644329-provide-fin-ai-agent-with-specific-guidance/page.tsx', [
('{Company name}', '{"{"} Company name {"}"}'),
])
# 4. help/en/articles/10644781 - Complex: <<i>company email</i>{">"}
fix_file('help/en/articles/10644781-fin-guidance-best-practices/page.tsx', [
('<<i>company email</i>{">"}"', '<<i>company email</i>>"'),
])
# 5. help/en/articles/10751648 - Unescaped { in JSON code
fix_file('help/en/articles/10751648-create-data-connectors-for-fin/page.tsx', [
('"to": "our_ticketing_email', '"to": "our_ticketing_email'),
])
# 6. help/en/articles/10763810 - This one seems to be at a position where the error is about something else
# Error at col 74617 - let me check what's actually there
# 7. help/en/articles/10840651 - Unescaped > in "Add filter > Language"
fix_file('help/en/articles/10840651-use-fin-ai-agent-in-multiple-languages/page.tsx', [
('> <b>Language</b>', '> <b>Language</b>'),
])
# 8. help/en/articles/10853206 - Unescaped > in "Edit > Add chart"
fix_file('help/en/articles/10853206-measure-and-report-on-fin-csat/page.tsx', [
('> <b>Add chart</b>', '> <b>Add chart</b>'),
])
# 9. help/en/articles/10903029 - Unescaped > in code example ">monthly_spend"
fix_file('help/en/articles/10903029-manage-audiences-and-targeting-for-fin/page.tsx', [
('<code>>monthly_spend', '<code>>monthly_spend'),
])
# 10. help/en/articles/10980759 - Multiple { that look like they should work (HTML entities)
# But the error is JSX parse - { renders as { which confuses JSX?
# Actually { in JSX IS a literal { character. Let me check more carefully.
# 11. help/en/articles/11077738 - Unescaped { in text "inserter {..}"
fix_file('help/en/articles/11077738-how-attributes-can-power-your-fin-tasks-escalations-workflows-and-data-connectors/page.tsx', [
('inserter {..}', 'inserter {"{"}..["}"}'),
])
# 12. help/en/articles/11115093 - Unescaped > in "Deploy >Salesforce cases >Install"
fix_file('help/en/articles/11115093-fin-for-salesforce-cases-required-permissions/page.tsx', [
('Deploy >Salesforce cases >Install', 'Deploy >Salesforce cases >Install'),
('Salesforce Setup ></b>', 'Salesforce Setup ></b>'),
])
# 13. help/en/articles/11116863 - Unescaped { in JS code: ("boot", {<br />
fix_file('help/en/articles/11116863-authenticating-users-in-fin-messenger-with-json-web-tokens-jwts/page.tsx', [
('("boot", {<br />', '("boot", {"{"}<br />'),
])
# 14. help/en/articles/11116923 - Unescaped { in JS code: payload = {<br />
fix_file('help/en/articles/11116923-migrating-from-identity-verification-to-messenger-security-with-jwts/page.tsx', [
('payload = {<br />', 'payload = {"{"}<br />'),
])
# 15. help/en/articles/11370516 - Unescaped < in "</body>" code reference
fix_file('help/en/articles/11370516-fin-messenger-setting-up-with-salesforce-miaw/page.tsx', [
('<code></body></code>', '<code></body></code>'),
])
# 16. help/en/articles/11470337 - Multiple unescaped > in SAML URL references
fix_file('help/en/articles/11470337-integrate-with-an-identity-provider-and-log-in-with-saml-sso/page.tsx', [
('<p>>You', '<p>>You'),
('<SAML URL>.</p>', '<SAML URL>.</p>'),
('</b>><SAML URL>/consume', '</b>><SAML URL>/consume'),
# There are multiple instances of this pattern
])
# 17. help/en/articles/11667266 - Unescaped > in "Settings > Zendesk Integration"
fix_file('help/en/articles/11667266-fin-for-zendesk-tickets-faqs/page.tsx', [
('> <b>Zendesk Integration</b>', '> <b>Zendesk Integration</b>'),
])
# 18. help/en/articles/11777290 - Unescaped > in "Settings > "
fix_file('help/en/articles/11777290-adding-or-removing-a-teammate/page.tsx', [
('>Settings > </a>', '>Settings > </a>'),
])
# 19. help/en/articles/11801771 - Unescaped { in JWT.encode({
fix_file('help/en/articles/11801771-sync-salesforce-account-data/page.tsx', [
('JWT.encode({email:', 'JWT.encode({"{"} email:'),
])
# 20. help/en/articles/11992116 - Unescaped { in JSON code
fix_file('help/en/articles/11992116-fin-messenger-map-data-using-salesforce-flows/page.tsx', [
('<pre>{<br /> "_firstName"', '<pre>{"{"}<br /> "_firstName"'),
])
# 21. help/en/articles/12066458 - Unescaped > in "Sites > (your site)"
fix_file('help/en/articles/12066458-fin-messenger-embedding-in-your-salesforce-portal/page.tsx', [
('Sites > (your site)', 'Sites > (your site)'),
])
# 22. help/en/articles/12313161 - Unescaped > in "Salesforce Setup >"
fix_file('help/en/articles/12313161-fin-messenger-required-permissions-for-salesforce/page.tsx', [
('Salesforce Setup ></b>', 'Salesforce Setup ></b>'),
])
# 23. help/en/articles/12586661 - Unescaped < in "<your_stripe_api_key>"
fix_file('help/en/articles/12586661-create-authentication-and-api-tokens/page.tsx', [
('<your_stripe_api_key>', '<your_stripe_api_key>'),
])
# 24. help/en/articles/12890230 - Unescaped { in JSON code
fix_file('help/en/articles/12890230-how-to-use-data-connectors-in-fin-procedures/page.tsx', [
('"order_id": "ORD-1001"', '"order_id": "ORD-1001"'),
])
# 25. help/en/articles/13703405 - Unescaped > in code: >(datetime
fix_file('help/en/articles/13703405-how-to-write-code-conditions-for-fin-procedures/page.tsx', [
('<pre>>(datetime', '<pre>>(datetime'),
])
# 26. salesforce-integration - xml:space namespace attribute
fix_file('salesforce-integration/page.tsx', [
('xml:space="preserve"', 'xmlSpace="preserve"'),
])
# 27. zendesk-integration - bare < in JSX text
fix_file('zendesk-integration/page.tsx', [
('"><</span>', '"><</span>'),
])
print("\n=== All fixes applied ===")