keep fallback to base.json, but tell user to use API key first
This commit is contained in:
parent
e05c8c6656
commit
1934b42438
@ -96,7 +96,7 @@ export const ReactiveResumeSection: React.FC<ReactiveResumeSectionProps> = ({
|
||||
<SelectValue placeholder="Select a base resume..." />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="none">None (Fallback to local base.json)</SelectItem>
|
||||
<SelectItem value="none">None (No profile data will be loaded)</SelectItem>
|
||||
{resumes.map((resume) => (
|
||||
<SelectItem key={resume.id} value={resume.id}>
|
||||
{resume.name}
|
||||
|
||||
@ -553,17 +553,23 @@ export function getPipelineStatus(): { isRunning: boolean } {
|
||||
* Load the user profile from JSON file.
|
||||
*/
|
||||
async function loadProfile(profilePath: string): Promise<Record<string, unknown>> {
|
||||
try {
|
||||
const rxResumeBaseResumeId = await settingsRepo.getSetting('rxResumeBaseResumeId');
|
||||
if (rxResumeBaseResumeId) {
|
||||
const rxResumeBaseResumeId = await settingsRepo.getSetting('rxResumeBaseResumeId');
|
||||
if (rxResumeBaseResumeId) {
|
||||
try {
|
||||
const resume = await getResume(rxResumeBaseResumeId);
|
||||
return resume.data as Record<string, unknown>;
|
||||
} catch (error) {
|
||||
console.error(`❌ Failed to load resume from Reactive Resume (${rxResumeBaseResumeId}):`, error);
|
||||
throw new Error(`Failed to load profile from Reactive Resume (ID: ${rxResumeBaseResumeId}). Please check your API key and connection.`);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const content = await readFile(profilePath, 'utf-8');
|
||||
return JSON.parse(content);
|
||||
} catch (error) {
|
||||
console.warn(`Failed to load profile from ${profilePath}, using empty object`, error);
|
||||
return {};
|
||||
const message = `No local profile found at ${profilePath} and no Reactive Resume base ID is configured. Reactive Resume integration is required for tailoring.`;
|
||||
console.error(`❌ ${message}`);
|
||||
throw new Error(message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,28 +13,25 @@ export const DEFAULT_RESUME_PROFILE_PATH =
|
||||
type ResumeProjectSelectionItem = ResumeProjectCatalogItem & { summaryText: string };
|
||||
|
||||
export async function loadResumeProfile(profilePath: string = DEFAULT_RESUME_PROFILE_PATH): Promise<unknown> {
|
||||
try {
|
||||
const rxResumeBaseResumeId = await getSetting('rxResumeBaseResumeId');
|
||||
if (rxResumeBaseResumeId) {
|
||||
const rxResumeBaseResumeId = await getSetting('rxResumeBaseResumeId');
|
||||
|
||||
if (rxResumeBaseResumeId) {
|
||||
try {
|
||||
const resume = await getResume(rxResumeBaseResumeId);
|
||||
return resume.data;
|
||||
} catch (error) {
|
||||
console.error(`❌ Failed to load resume from Reactive Resume (${rxResumeBaseResumeId}):`, error);
|
||||
throw new Error(`Failed to load profile from Reactive Resume (ID: ${rxResumeBaseResumeId}). Please check your API key and connection.`);
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to local file
|
||||
try {
|
||||
const { readFile } = await import('fs/promises');
|
||||
const content = await readFile(profilePath, 'utf-8');
|
||||
return JSON.parse(content);
|
||||
} catch (error) {
|
||||
console.warn(`Failed to load profile, using fallback if possible`, error);
|
||||
// If Reactive Resume failed but we have a path, try reading file
|
||||
if (profilePath) {
|
||||
try {
|
||||
const { readFile } = await import('fs/promises');
|
||||
const content = await readFile(profilePath, 'utf-8');
|
||||
return JSON.parse(content);
|
||||
} catch (innerError) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
console.warn(`⚠️ No local profile found at ${profilePath} and no Reactive Resume base ID is configured. Reactive Resume integration is required for tailoring.`);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user