Skip to content

Commit 7d435d4

Browse files
fix: remove non-existent single-tag API endpoint causing 405 errors
The Toggl v9 API doesn't support GET /workspaces/{wid}/tags/{tagId}. CacheManager.getTag() now uses getTags() to bulk-fetch and cache all tags for the workspace, eliminating repeated 405 failures during time entry hydration. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5dddd55 commit 7d435d4

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

src/cache-manager.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -237,19 +237,12 @@ export class CacheManager {
237237
async getTag(id: number, workspaceId: number): Promise<Tag | null> {
238238
const cached = this.getCached(this.tags, id);
239239
if (cached) return cached;
240-
240+
241241
if (!this.api) return null;
242-
243-
try {
244-
const tag = await this.api.getTag(workspaceId, id);
245-
if (tag) {
246-
this.setCached(this.tags, id, tag);
247-
}
248-
return tag;
249-
} catch (error) {
250-
console.error(`Failed to fetch tag ${id}:`, error);
251-
return null;
252-
}
242+
243+
// Fetch all tags for the workspace (populates cache) and find by ID
244+
const tags = await this.getTags(workspaceId);
245+
return tags.find(t => t.id === id) || null;
253246
}
254247

255248
async getTags(workspaceId: number): Promise<Tag[]> {

src/toggl-api.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,6 @@ export class TogglAPI {
154154
return this.request<Tag[]>('GET', `/workspaces/${workspaceId}/tags`);
155155
}
156156

157-
async getTag(workspaceId: number, tagId: number): Promise<Tag> {
158-
return this.request<Tag>('GET', `/workspaces/${workspaceId}/tags/${tagId}`);
159-
}
160-
161157
async createTag(workspaceId: number, name: string): Promise<Tag> {
162158
return this.request<Tag>('POST', `/workspaces/${workspaceId}/tags`, { name });
163159
}

0 commit comments

Comments
 (0)