Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cmd/nlm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,20 @@ func listSources(c *api.Client, notebookID string) error {
return fmt.Errorf("list sources: %w", err)
}

// Removed auth check that was masking beprotojson array nesting bug

// Debug: print project details
if debug {
fmt.Fprintf(os.Stderr, "=== Project Debug ===\n")
fmt.Fprintf(os.Stderr, "Project ID: %s\n", p.ProjectId)
fmt.Fprintf(os.Stderr, "Project Title: %s\n", p.Title)
fmt.Fprintf(os.Stderr, "Sources count: %d\n", len(p.Sources))
for i, src := range p.Sources {
fmt.Fprintf(os.Stderr, "Source %d: %+v\n", i, src)
}
fmt.Fprintf(os.Stderr, "=====================\n")
}

w := tabwriter.NewWriter(os.Stdout, 0, 4, 4, ' ', 0)
fmt.Fprintln(w, "ID\tTITLE\tTYPE\tSTATUS\tLAST UPDATED")
for _, src := range p.Sources {
Expand Down
28 changes: 28 additions & 0 deletions internal/api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,38 @@ func (c *Client) GetProject(projectID string) (*Notebook, error) {
return nil, fmt.Errorf("get project: %w", err)
}

// Debug: Print raw response before unmarshaling
if c.rpc.Config.Debug {
fmt.Fprintf(os.Stderr, "=== GetProject Raw Response ===\n")
fmt.Fprintf(os.Stderr, "Response length: %d bytes\n", len(resp))
previewLen := 500
if len(resp) < previewLen {
previewLen = len(resp)
}
fmt.Fprintf(os.Stderr, "Response preview: %s\n", string(resp[:previewLen]))
fmt.Fprintf(os.Stderr, "================================\n")
}

// Sources nesting issue is now fixed in beprotojson package

var project pb.Project
if err := beprotojson.Unmarshal(resp, &project); err != nil {
return nil, fmt.Errorf("parse response: %w", err)
}

// Debug: Print parsed project after unmarshaling
if c.rpc.Config.Debug {
fmt.Fprintf(os.Stderr, "=== GetProject Parsed Result ===\n")
fmt.Fprintf(os.Stderr, "Project ID: '%s'\n", project.ProjectId)
fmt.Fprintf(os.Stderr, "Project Title: '%s'\n", project.Title)
fmt.Fprintf(os.Stderr, "Project Emoji: '%s'\n", project.Emoji)
fmt.Fprintf(os.Stderr, "Sources count: %d\n", len(project.Sources))
if len(project.Sources) > 0 {
fmt.Fprintf(os.Stderr, "First source: %+v\n", project.Sources[0])
}
fmt.Fprintf(os.Stderr, "=================================\n")
}

return &project, nil
}

Expand Down
8 changes: 8 additions & 0 deletions internal/beprotojson/beprotojson.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ func (o UnmarshalOptions) Unmarshal(b []byte, m proto.Message) error {
func (o UnmarshalOptions) populateMessage(arr []interface{}, m proto.Message) error {
msg := m.ProtoReflect()
fields := msg.Descriptor().Fields()
msgName := string(msg.Descriptor().FullName())

// Special handling for Project message: unwrap extra nesting from GetProject API
if msgName == "notebooklm.v1alpha1.Project" && len(arr) == 1 {
if innerArr, ok := arr[0].([]interface{}); ok {
arr = innerArr
}
}

for i, value := range arr {
if value == nil {
Expand Down